persistent highlights do not persist in crosstalk SharedData$selection()
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
When using plotly with crosstalk, and highlight(..., persistent = TRUE), the selections do not synchronize as expected with SharedData$selection(). Only the last selection is selected in the SharedData object. previous ones are "forgotten". The plot highlights will be out of sync with the SharedData object.
library(tidyverse)
library(plotly)
library(crosstalk)
library(shiny)
ui <- bootstrapPage(
wellPanel(
plotlyOutput(outputId = "plot"),
verbatimTextOutput(outputId = "selection")
)
)
server <- function(input, output, session) {
data <- mtcars %>%
rownames_to_column("name") %>%
SharedData$new()
output$plot <- renderPlotly({
plot_ly(data = data, x = ~disp, y = ~mpg, mode = "marker", type = "scatter") %>%
highlight(on = "plotly_selected", off = "plotly_deselect", persistent = TRUE)
})
output$selection <- renderPrint({
s <- data$selection()
print(paste(sum(s), "points selected"))
})
}
shinyApp(ui = ui, server = server)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied R/Shiny reproducible example with plotly, crosstalk, and persistent highlighting. Trace how repeated plotly selections are synchronized with SharedData$selection(), then verify that all persistent selections remain available in the SharedData object and the displayed count stays in sync.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100