hovertemplate does not show value
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
When using the %{text} placeholder, it sometimes gets displayed instead of the actual value of text. The following code produces a plot where, when I hover over the middle point, gives me this hover text:
Price: $6.84
X: 3
%{text}
Other points display correctly, eg.
Price: $2.03
X: 1
Text A
The code I use is a slightly modified example:
tibble::tibble(
x = c(1,2,3,4,5),
y = c(2.02825,1.63728,6.83839,4.8485,4.73463),
color = factor(c(1, 1, 2, 3, 3))) %>%
plot_ly() %>%
add_trace(
type = 'scatter', mode = 'lines+markers',
x = ~x, y = ~y, color = ~color,
text = c("Text A", "Text B", "Text C", "Text D", "Text E"),
hovertemplate = paste('<i>Price</i>: $%{y:.2f}',
'<br><b>X</b>: %{x}<br>',
'<b>%{text}</b>'),
showlegend = FALSE)
You can donwload the resulting html here (in case it renders differently for you for some reason). Note that when color is not used, this does not happen and all the points display correct hover text.
R version 3.6.3 (2020-02-29)
plotly 4.9.2.1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用列出的 R 和 plotly 版本运行提供的 plot_ly() 和 add_trace() 示例,然后比较有色和无色的 traces。确认中间点是否仍然渲染 %{text} 而不是 Text C,并利用这一比较追踪 hovertemplate 的处理方式。没有指定源文件或测试,因此当 reproducer 为每个点显示实际文本时即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100