Learn R Programming

linevis (version 1.0.0)

centerTime: Move the window such that the given time is centered

Description

Move the window such that the given time is centered

Usage

centerTime(id, time, options)

Value

None, side-effect is Javascript call

Arguments

id

graph2d id or a linevis object (the output from linevis())

time

The date/time to center around

options

Named list of options controlling the animation. Most common option is "animation" = TRUE/FALSE. For a full list of options, see the "moveTo" method in the official graph2d documentation

Examples

Run this code
if (FALSE) {
linevis() %>%
  centerTime(Sys.Date() - 1)
}

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    linevisOutput("graph2d"),
    actionButton("btn", "Center around 24 hours ago")
  ),
  server = function(input, output) {
    output$graph2d <- renderLinevis(
      linevis()
    )
    observeEvent(input$btn, {
      centerTime("graph2d", Sys.Date() - 1)
    })
  }
)
}

Run the code above in your browser using DataLab