Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add* / set* / center* etc dont work in shiny modules #90

Closed
trafficonese opened this issue Jan 8, 2020 · 2 comments
Closed

add* / set* / center* etc dont work in shiny modules #90

trafficonese opened this issue Jan 8, 2020 · 2 comments

Comments

@trafficonese
Copy link

It seems necessary to include the module id for the functions to work. Could they do that automagically?

library(shiny)
library(timevis)

## Data ################
dataBasic <- data.frame(
  id = 1:4,
  content = c("Item one", "Item two" ,"Ranged item", "Item four"),
  start   = c("2016-01-10", "2016-01-11", "2016-01-20", "2016-02-14"),
  end    = c(NA, NA, "2016-02-04", NA)
)

## Module ####################
timevis_ui <- function(id) {
  ns <- NS(id)
  tagList(
    timevisOutput(ns("timevisui")),
    verbatimTextOutput(ns("timevissel")),
    actionButton(ns("setwindow"), label = "Set Window")
  )
}
timevis_server <- function(input, output, session) {
  output$timevisui <- renderTimevis({
    timevis(data = dataBasic)
  })
  observeEvent(input$timevisui_selected, {
    print("Center object to "); print(input$timevisui_selected)
    ## Works
    # centerItem("tmv-timevisui", input$timevisui_selected)
    ## Doesnt work
    centerItem("timevisui", input$timevisui_selected)
  })
  observeEvent(input$setwindow, {
    print("Set Window")
    ## Works
    # setWindow("tmv-timevisui", "2016-01-10", "2016-05-10")
    ## Doesnt work
    setWindow("timevisui", "2016-01-10", "2016-05-10")
  })
}

## Shiny ###########################
ui <- fluidPage(timevis_ui("tmv"))
server <- function(input, output, session) {callModule(timevis_server,  "tmv")}
shinyApp(ui, server)
@daattali
Copy link
Owner

daattali commented Jan 9, 2020

Could you try the latest github version and verify that it works as you expect now?

@trafficonese
Copy link
Author

yes, its working. Thanks for the quick fix!

strazto pushed a commit to strazto/timevis that referenced this issue Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants