removeItem: Remove an item from a timeline

View source: R/api.R

removeItemR Documentation

Remove an item from a timeline

Description

Remove an item from a timeline

Usage

removeItem(id, itemId)

Arguments

id

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

itemId

The id of the item to remove

Examples

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

## End(Not run)

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

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