plotly / plotly/plotly.R

Hover incorrect when supplying color as argument in add_trace

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

还没有人认领这个 Issue。

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

描述

I tried to create complex plot using add_trace. However there is problem with the hover when supplying color as argument: In this case the first and last element of the trace has no hover, sometimes it is only the first or only the last:

p1 <- plot_ly() |> 
  add_trace(
    type = "scatter",
    mode = "markers",
    x = 1:3,
    y = 1,
    color = 1:3,
    marker = list(colorscale = list(list(0, "red"), list(1, "orange")))
  )
p1

It works fine with

p2 <- plot_ly() |> 
  add_trace(
    type = "scatter",
    mode = "markers",
    x = 1:3,
    y = 1,
    marker = list(color = 1:3, colorscale = list(list(0, "red"), list(1, "orange")))
  )
p2

When doing the equivalent thing in python with

from plotly import graph_objects as go
fig2 = go.Figure()
fig2.add_trace(
    go.Scatter(x=[1,2,3], y=[1,1,1], type="scatter", mode="markers", marker={"color":[1,2,3], "colorscale":[[0,"red"],[1,"orange"]]})
)
fig1 = go.Figure()
fig1.add_trace(
    go.Scatter(x=[1,2,3], y=[1,1,1], type="scatter", mode="markers", color=[1,2,3], marker={"colorscale":[[0,"red"],[1,"orange"]]})
)

you get an error instead of an incorrect graph, which is better, I would claim.

贡献指南

打开贡献指南

从这里开始

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

调研方向

使用提供的 R add_trace 复现作为切入点,比较 p1 与 p2,并检查所报告的端点 hover 行为。当 color-as-argument 情况不再丢失第一个或最后一个点的 hover 信息,且这些示例作为回归检查时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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