plotly / plotly/plotly.R

layout.shapes.legendgroup is unexpectedly non-functional

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

还没有人认领这个 Issue。

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

描述

layout.shapes.legendgroup is non-functional although included in the official reference (https://plotly.com/r/reference/layout/shapes/)

In the below reprex, I have set all objects to the same legendgroup. I would expect them all to disappear when clicking on the legend but this does not happen.

library(plotly)
x <- seq(-2 * pi, 2 * pi, length.out = 1000)
df <- data.frame(x, y1 = sin(x), y2 = cos(x))

fig <-
  plot_ly(df, x = ~x) %>%
  add_lines(y = ~y1, name = "A", legendgroup = "B") %>%
  add_lines(y = ~y2, name = "B", legendgroup = "B")

fig %>% 
  plotly::layout(shapes = 
                   list(
                     list(type = "rect",
                          fillcolor = "blue", line = list(color = "blue"), opacity = 0.3,
                          x0 = -1, x1 = 1, xref = "x",
                          y0 = -0.5, y1 = 0.5, yref = "y", legendgroup = "B")))

Example adapted from https://plotly.com/r/dropdowns/

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行提供的 R reprex,并将 shape 的 legendgroup 行为与两个折线 trace 进行比较。将 layout.shapes 参考作为预期行为;完成的标准是点击共享的图例项时,shape 会与分组的 trace 一起隐藏和显示。

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

评估

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

把新 issue 发到你的邮箱

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