Move the window such that the given time is centered
centerTime(id, time, options)
Timeline id or a timevis
object (the output from timevis()
)
The date/time to center around
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
Timeline documentation
timevis() %>%
centerTime(Sys.Date() - 1)
if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
timevisOutput("timeline"),
actionButton("btn", "Center around 24 hours ago")
),
server = function(input, output) {
output$timeline <- renderTimevis(
timevis()
)
observeEvent(input$btn, {
centerTime("timeline", Sys.Date() - 1)
})
}
)
}