plotly / plotly/plotly.R

selectedpoints for curvenumber > 0 invisible when using scattergl

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

还没有人认领这个 Issue。

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

描述

I'm not sure if this is an issue with the R library (latest CRAN version 4.12.0) or plotly.js however, when setting selectedpoints on a scattergl trace for curvenumbers > 0, the points turn invisible - for curvenumber 0 it works as it should. If you look closely, you can see that the points were faded out before they are selected and when selected they disappear.

Using a scatter trace instead everything works as expected.

Image

library(shiny)
library(plotly)

DF <- data.frame(
  x = rep(1:10, 3),
  y = c(
    seq(1, 5, length.out = 10),
    seq(1, 7, length.out = 10),
    seq(1, 10, length.out = 10)
  ),
  grp = rep(LETTERS[1:3], each = 10)
)

ui <- fluidPage(
  plotlyOutput("my_plot"),
  selectInput("plot_type", "Plot Type", choices = c("scatter", "scattergl"), selected = "scatter"),
  numericInput(
    inputId = "point_number",
    label = "Point Number",
    value = 0,
    min = 0,
    max = 9
  ),
  numericInput(
    inputId = "curve_number",
    label = "Curve Number",
    value = 0,
    min = 0,
    max = 2
  )
)

server <- function(input, output, session) {
  my_plot_proxy <- plotlyProxy(
    outputId = "my_plot"
  )
  
  observe({
    plotlyProxyInvoke(my_plot_proxy, "restyle", list(selectedpoints = -1)) # deselect all points for all traces
    plotlyProxyInvoke(my_plot_proxy, "restyle", list(selectedpoints = list(I(input$point_number))), input$curve_number)
  })
  
  output$my_plot <- renderPlotly({
    plot_ly(data = DF, type = input$plot_type, mode = "lines+markers", x = ~x, y = ~y, name = ~grp)
  })
}

shinyApp(ui, server)

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 issue 中最小的 Shiny 复现开始,在改变 curve_number 和 selectedpoints 的同时比较 scatter 与 scattergl。跟踪非零 trace 的 plotlyProxyInvoke restyle 路径;当每条曲线的选定点都保持可见,并与 scatter 的行为一致时,issue 即完成。

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

评估

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

把新 issue 发到你的邮箱

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