setSelection: Select one or multiple items on a timeline

View source: R/api.R

setSelectionR Documentation

Select one or multiple items on a timeline

Description

Select one or multiple items on a timeline

Usage

setSelection(id, itemId, options)

Arguments

id

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

itemId

A vector (or single value) of the item ids to select

options

Named list of options controlling mainly the animation. Most common options are focus = TRUE/FALSE and "animation" = TRUE/FALSE. For a full list of options, see the "setSelection" method in the official Timeline documentation

Examples

## Not run: 
timevis(data.frame(id = 1:3, start = Sys.Date(), content = 1:3)) %>%
  setSelection(2)

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn", "Select item 2")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis(
        data.frame(id = 1:3, start = Sys.Date(), content = 1:3)
      )
    )
    observeEvent(input$btn, {
      setSelection("timeline", 2)
    })
  }
)
}

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