removeCustomTime: Remove a custom time previously added

View source: R/api.R

removeCustomTimeR Documentation

Remove a custom time previously added

Description

Remove a custom time previously added

Usage

removeCustomTime(id, itemId)

Arguments

id

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

itemId

The id of the custom time bar

Examples

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

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn0", "Add custom time"),
    actionButton("btn", "Remove custom time bar")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis()
    )
    observeEvent(input$btn0, {
      addCustomTime("timeline", Sys.Date() - 1, "yesterday")
    })
    observeEvent(input$btn, {
      removeCustomTime("timeline", "yesterday")
    })
  }
)
}

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