-
Notifications
You must be signed in to change notification settings - Fork 171
handle_click not working in shiny modules #457
Comments
This also seems to be the case for
|
Came across the same problem trying to get Seems like library(shiny)
library(ggvis)
m <- function(input, output, session){
mtcars %>% ggvis(~mpg, ~disp) %>%
layer_points() %>%
handle_click(function(location,...){print(location)}) %>%
bind_shiny("plot-plot", session = getDefaultReactiveDomain()[["parent"]])
}
ui <- fluidPage(
ggvisOutput("plot-plot"),
ggvisOutput("plot-plot2")
)
server <- function(input, output, session) {
callModule(m, 'plot')
mtcars %>% ggvis(~mpg, ~disp) %>%
layer_points() %>%
handle_click(function(location,...){print(location)}) %>%
bind_shiny("plot-plot2")
}
shinyApp(ui = ui, server = server) But this feels a little like it's going against the principles of modules (it probably wouldn't work nicely if you start nesting modules). It seems to work ok with multiple instances of the same module, i.e. library(shiny)
library(ggvis)
m_output <- function(id){
ns <- NS(id)
ggvisOutput(ns("plot"))
}
m <- function(input, output, session){
ns <- session$ns
tmp <- mtcars %>% ggvis(~mpg, ~disp) %>%
layer_points() %>%
handle_click(function(location,...){print(location)}) %>%
bind_shiny(ns("plot"),
session = getDefaultReactiveDomain()[["parent"]])
}
ui <- fluidPage(
m_output("plot1"),
m_output("plot2")
)
server <- function(input, output, session) {
callModule(m, "plot1")
callModule(m, "plot2")
}
shinyApp(ui = ui, server = server) |
Is there any other workaround to this issue? For my module that uses ggvis and |
I also see the "bind_shiny() must be run inside a shiny app." error. Is the only currently functioning workaround to just re-scope modules around ggvis bindings? |
See example below for bug:
both plots are displayed, but click events are only registered in the first plot.
The text was updated successfully, but these errors were encountered: