Using Shift on event_data("plotly_click") only stores last key
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
When using the SHIFT-key on a plotly_click event, it returns only the last clicked key, whereas using SHIFT on plotly_selected stores all selected keys.
Is it possible to adapt the event_data("plotly_click") to be consistent with the highlighting and return all clicked/highlighted elements?
Or can I deactivate SHIFT for click-events alltogether and leave it activated for selection-events?

Shiny-App:
library(shiny)
library(ggplot2)
library(plotly)
dfN <- data.frame(
time_stamp = seq.Date(as.Date("2018-04-01"), as.Date("2018-07-30"), 1),
val = runif(121, 100,1000),
col = "green", stringsAsFactors = F
)
ui <- fluidPage(
plotlyOutput("plot"),
verbatimTextOutput("clicked"),
verbatimTextOutput("selection")
)
server <- function(input, output, session) {
output$plot <- renderPlotly({
key <- highlight_key(dfN)
p <- ggplot() +
geom_col(data = key, aes(x = plotly:::to_milliseconds(time_stamp), y = val, fill=I(col))) +
theme(legend.position="none")
ggplotly(p, source = "Src") %>% layout(xaxis = list(tickval = NULL, ticktext = NULL, type = "date")) %>%
highlight(selectize=F, off = "plotly_doubleclick", on = "plotly_click", color = "blue",
opacityDim = 0.5, selected = attrs_selected(opacity = 1))
})
output$clicked <- renderPrint({
s <- event_data("plotly_click", source = "Src")
s
})
output$selection <- renderPrint({
s <- event_data("plotly_selected", source = "Src")
s
})
}
shinyApp(ui, 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
Start with the minimal Shiny app in the issue and trace event_data("plotly_click") alongside highlight() and event_data("plotly_selected"). Compare how Shift-click state is represented for both events, then define completion as either returning all highlighted keys for click events or documenting and implementing a way to disable Shift for clicks while retaining selection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, r
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100