Here is my code for a basic brilliant application that uses the plotly_click event to optionally display a different plot. I would like this sidebar graph to appear in a modal popup, rather than the side of the page.
library(shiny) library(plotly) df1 <- data.frame(x = 1:10, y = 1:10) df2 <- data.frame(x = c(rep('a', 10), rep('b', 10)), y = c(rnorm(10), rnorm(10, 3, 1))) ui <- fluidPage( column(6, plotlyOutput('scatter')), column(6, plotlyOutput('box')) ) server <- function(input, output) { output$scatter <- renderPlotly({ plot_ly(df1, x = x, y = y, mode = 'markers', source = 'scatter') }) output$box <- renderPlotly({ eventdata <- event_data('plotly_click', source = 'scatter') validate(need(!is.null(eventdata), 'Hover over the scatter plot to populate this boxplot')) plot_ly(df2, x = x, y = y, type = 'box') }) } shinyApp(ui = ui, server = server)
I was able to complete this question ( Shiny: display the results in a popup ) and answer and tried to use it with trigger of plotly_click unsuccessfully. Any idea on how to pull out the same with a plot click?
UPDATE: I can clearly see that the graph plotly can be displayed in shinyBS modal popup, as shown in this code.
df1 <- data.frame(x = 1:10, y = 1:10) ui <- fluidPage( actionButton('go', 'Click Go'), bsModal('plotlyPlot', 'Here is a Plot', 'go', plotlyOutput('scatter1')) ) server <- function(input, output) { output$scatter1 <- renderPlotly({ plot_ly(df2, x = x, y = y, mode = 'markers', source = 'scatter1') }) } shinyApp(ui = ui, server = server)
Instead of an actionButton as a trigger, I want to plotly_click or plotly_hover , as it is, a trigger (in the original example).