setItems: Set the items of a timeline

View source: R/api.R

setItemsR Documentation

Set the items of a timeline

Description

Set the items of a timeline

Usage

setItems(id, data)

Arguments

id

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

data

A dataframe containing the item data to use.

Examples

## Not run: 
timevis(data.frame(start = Sys.Date(), content = "Today")) %>%
  setItems(data.frame(start = Sys.Date() - 1, content = "yesterday"))

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn", "Change the data to yesterday")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis(data.frame(start = Sys.Date(), content = "Today"))
    )
    observeEvent(input$btn, {
      setItems("timeline",
               data.frame(start = Sys.Date() - 1, content = "yesterday"))
    })
  }
)
}

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