Add a new vertical bar at a time point that can be dragged by the user

Share:

Description

Add a new vertical bar at a time point that can be dragged by the user

Usage

1
addCustomTime(id, time, itemId)

Arguments

id

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

time

The date/time to add

itemId

The id of the custom time bar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
timevis() %>%
  addCustomTime(Sys.Date() - 1, "yesterday")

if (interactive()) {
library(shiny)
shinyApp(
  ui = fluidPage(
    timevisOutput("timeline"),
    actionButton("btn", "Add time bar 24 hours ago")
  ),
  server = function(input, output) {
    output$timeline <- renderTimevis(
      timevis()
    )
    observeEvent(input$btn, {
      addCustomTime("timeline", Sys.Date() - 1, "yesterday")
    })
  }
)
}