You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a plotly plot listens for both click and selected events, I expect the click event to trigger every time a point is clicked, and the selected event to trigger every time a box/lasso selection is made.
It seems like whenever a click happens, unless the previous action was also a click, the selected event also gets triggered (with empty data, so essentially it clears the selection).
Here's a GIF of this issue
Here's my code:
library(shiny)
library(plotly)
ui <- fluidPage(
plotlyOutput("plot"),
verbatimTextOutput("click"),
verbatimTextOutput("brush")
)
server <- function(input, output, session) {
nms <- row.names(mtcars)
output$plot <- renderPlotly({
p <- ggplot(mtcars, aes(x = mpg, y = wt, key = nms)) + geom_point()
ggplotly(p) %>% layout(dragmode = "lasso")
})
output$click <- renderPrint({
message('clicked')
d <- event_data("plotly_click")
if (!is.null(d)) d
})
output$brush <- renderPrint({
message('selected')
d <- event_data("plotly_selected")
if (!is.null(d)) d
})
}
shinyApp(ui, server)
The text was updated successfully, but these errors were encountered:
When a plotly plot listens for both
click
andselected
events, I expect the click event to trigger every time a point is clicked, and the selected event to trigger every time a box/lasso selection is made.It seems like whenever a click happens, unless the previous action was also a click, the selected event also gets triggered (with empty data, so essentially it clears the selection).
Here's a GIF of this issue
Here's my code:
The text was updated successfully, but these errors were encountered: