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

未關閉
#1,401 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
38/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
javascript, r

研究方向

從 issue 中的最小 Shiny 應用程式開始,同時追蹤 event_data("plotly_click")、highlight() 和 event_data("plotly_selected")。比較兩個事件中 Shift-click 狀態的表示方式,然後將完成標準定義為:對於點擊事件返回所有突顯的鍵,或記錄並實作一種在保留選取行為的同時停用點擊時 Shift 的方式。

由索引模型根據 Issue 內容生成。

描述

difficulty: medium enhancement shiny

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)
主要語言
R
星號
2.7k
分支
641
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

plotly/plotly.R 的其他 Issue

查看 plotly/plotly.R 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。