setCustomTime: Adjust the time of a custom time bar

View source: R/api.R

setCustomTimeR Documentation

Adjust the time of a custom time bar

Description

Adjust the time of a custom time bar

Usage

setCustomTime(id, time, itemId)

Arguments

id

Timeline id or a timevis object (the output from timevis())

time

The new date/time

itemId

The id of the custom time bar

Examples

## Not run: 
timevis() %>%
  addCustomTime(Sys.Date(), "yesterday") %>%
  setCustomTime(Sys.Date() - 1, "yesterday")

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn", "Set time bar 24 hours ago")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis() %>% addCustomTime(Sys.Date(), "yesterday")
    )
    observeEvent(input$btn, {
      setCustomTime("timeline", Sys.Date() - 1, "yesterday")
    })
  }
)
}

timevis documentation built on Nov. 3, 2022, 9:06 a.m.