I am looking to add a click event to a shiny app that has 2 sund2b plots on the page. I would like the text output to just be in reference to whichever plot they clicked last, however it only seems to react to the first plot and not the second. The output is great for the one but I would like it to work for both. This is a simplified example of what I have:
library(shiny)
library(sunburstR)
sequences <- read.csv(
system.file("examples/visit-sequences.csv",package="sunburstR")
,header = FALSE
,stringsAsFactors = FALSE
)[1:200,]
sequences2 <- read.csv(
system.file("examples/visit-sequences.csv",package="sunburstR")
,header = FALSE
,stringsAsFactors = FALSE
)[201:400,]
server <- function(input,output,session){
#sunburst1
output$sunburst <- renderSund2b({
add_shiny(sund2b(sequences))
})
#sunburst2
output$sunburst2 <- renderSund2b({
add_shiny(sund2b(sequences2))
})
#sunburst click event
selection <- reactive({
input$sunburst_click
})
output$selection <- renderText(selection())
}
ui<-fluidPage(
sidebarLayout(
sidebarPanel(
),
# plot sunburst
mainPanel(
sund2bOutput("sunburst"),
sund2bOutput("sunburst2"),
textOutput("selection")
)
)
)
shinyApp(ui = ui, server = server)
question from:https://stackoverflow.com/questions/66053447/add-click-event-to-shiny-app-with-2-sunburstr-plots