addItems: Add multiple items to a timeline

View source: R/api.R

addItemsR Documentation

Add multiple items to a timeline

Description

Add multiple items to a timeline

Usage

addItems(id, data)

Arguments

id

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

data

A dataframe containing the items data to add.

Examples

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

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn", "Add items today and yesterday")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis()
    )
    observeEvent(input$btn, {
      addItems("timeline",
               data.frame(start = c(Sys.Date(), Sys.Date() - 1),
                          content = c("Today", "Yesterday")))
    })
  }
)
}

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