addItem: Add a single item to a timeline

View source: R/api.R

addItemR Documentation

Add a single item to a timeline

Description

Add a single item to a timeline

Usage

addItem(id, data)

Arguments

id

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

data

A named list containing the item data to add.

Examples

## Not run: 
timevis() %>%
  addItem(list(start = Sys.Date(), content = "Today"))

## End(Not run)

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn", "Add item today")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis()
    )
    observeEvent(input$btn, {
      addItem("timeline", list(start = Sys.Date(), content = "Today"))
    })
  }
)
}

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