daattali / timevis

📅 Create interactive timeline visualizations in R
http://daattali.com/shiny/timevis-demo/
Other
652 stars 157 forks source link

Example of using timevis in R shiny moduls, not working #93

Closed am2222 closed 4 years ago

am2222 commented 4 years ago

Hi, Following my previous issue here ( https://github.com/daattali/timevis/issues/92) the following code does not work

library(shiny)
library(timevis)

timevis_ui <- function(id) {
  ns <- NS(id)
  tagList(
    timevisOutput(ns("timevisui")),
    actionButton(ns("add"), "Add")
  )
}
timevis_server <- function(input, output, session) {
  output$timevisui <- renderTimevis({
    timevis()
  })
  observeEvent(input$add, {
    addItem("timevisui", list(start = Sys.Date()-2, content = "Two days ago"))
  })
}

ui <- fluidPage(
  timevis_ui("test")
)
server <- function(input, output, session) {
  callModule(timevis_server,  "test")
}
shinyApp(ui, server)

In that thread the code was adding a line on the sys.Date() which is already added by default. If we change start to another date it does not add anything.

daattali commented 4 years ago

Thanks, will take a look

daattali commented 4 years ago

The code you provided does work.

It's possible you might be using an old version of the package. Please install the latest version with remotes::install_github("daattali/timevis").

I'm closing this issue as I really believe there is no problem - if you still see a problem with current version, do feel free to open another issue, and also include your session information (by running devtools::session_info())