plotly / plotly/plotly.R

Using Shift on event_data("plotly_click") only stores last key

未关闭
#1,401 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

difficulty: medium enhancement shiny
主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

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?

clickselect

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)

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 issue 中的最小 Shiny 应用开始,同时跟踪 event_data("plotly_click")、highlight() 和 event_data("plotly_selected")。比较两个事件中 Shift-click 状态的表示方式,然后将完成标准定义为:对于点击事件返回所有突出显示的键,或者记录并实现一种在保留选择行为的同时禁用点击时 Shift 的方式。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, r
领域
data-visualization, frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。