I use @shosaco solution from here to reset selection in plotly:
library(shiny)
library(plotly)
library(shinyjs)
library(V8)
ui <- shinyUI(
fluidPage(
useShinyjs(),
extendShinyjs(text = "shinyjs.resetClick = function() { Shiny.onInputChange('.clientValue-plotly_selected-A', 'null'); }"),
actionButton("reset", "Reset plotly click value"),
plotlyOutput("plot"),
verbatimTextOutput("clickevent")
)
)
server <- shinyServer(function(input, output) {
output$plot <- renderPlotly({
plot_ly(mtcars, x=~cyl, y=~mpg)
})
output$clickevent <- renderPrint({
event_data("plotly_selected")
})
observeEvent(input$reset, {
js$resetClick()
})
})
shinyApp(ui, server)
and it works with resetting data but does not reset marked rectangle:
Do you have any ideas how to get rid of that rectangle?