`updatemenus` > `buttons` don't behave as expected when restyling `y` axis (ignores `color` channel)
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
library(plotly)
dat <- structure(list(date = structure(c(1230768000, 1230771600, 1230775200,
1230778800, 1230782400, 1230786000, 1230789600, 1230793200, 1230796800,
1230800400, 1230768000, 1230771600, 1230775200, 1230778800, 1230782400,
1230786000, 1230789600, 1230793200, 1230796800, 1230800400, 1230768000,
1230771600, 1230775200, 1230778800, 1230782400, 1230786000, 1230789600,
1230793200, 1230796800, 1230800400, 1230768000, 1230771600, 1230775200,
1230778800, 1230782400, 1230786000, 1230789600, 1230793200, 1230796800,
1230800400), tzone = "GMT", class = c("POSIXct", "POSIXt")),
nox = c(113, 40, 48, 36, 40, 50, 50, 53, 80, 111, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 130, 63, 76, 69, 61, 61,
61, 92, 57, 50, 31, 34, 27, 19, 21, 25, 19, 31, 42, 48),
pm10 = c(46, 49, 46, NA, 38, 32, 36, 32, 30, 32, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 53, 46, 45, 43, 37, 35, 37,
38, 33, 31, 44, 39, 40, 35, 34, 30, 28, 31, 29, 27), site = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), levels = c("1", "2",
"3", "4"), class = "factor")), row.names = c(NA, -40L), class = c("tbl_df",
"tbl", "data.frame"))
plot_ly(x = dat$date, y = dat$nox) |>
add_lines(color = dat$site) |>
layout(updatemenus = list(list(
type = "buttons",
y = 0.8,
buttons = list(
list(
method = "restyle",
args = list("y", list(dat$nox)),
label = "NO<sub>x</sub>"
),
list(
method = "restyle",
args = list("y", list(dat$pm10)),
label = "PM<sub>10</sub>"
)
)
)))
I would imagine that clicking the "NOx" button would do effectively nothing, but instead it seems to strip away the color feature of the plot.
Before clicking:
After clicking:
Am I doing something wrong, or is this a bug?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行提供的 R 复现代码,使用 plot_ly()、add_lines(color = dat$site) 以及调用 restyle 处理 y 的 layout updatemenus 按钮。跟踪该 restyle 如何影响带颜色的 traces;完成的标准是,在 NOx 和 PM10 之间切换会改变 y 数据,同时不会移除按 site 颜色分组。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100