hovertemplate not parsed with text input
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hello plotly.R,
I'm using the hovertemplate in a bar chart with my data segmented using the color argument. I wish to use the text value in my hovertemplate.
The issue is that the template is not processed for one of my two segments.
Run the below code, and hover on the three bars. For the first two, the hover info is correct, for the last one, it shows the template part where the text is supposed to go.
Note 1: replacing text with y works in this case. But there could be a case where I really need the text and not the y.
Note 2: the texttemplate does not have this issue and correctly shows the value of the text in all three bars.
library(plotly)
df <- data.frame(year = c('2021', '2020', '2019'), value = c(123, 110, 95))
plot_ly(data = df, x=~year, y=~value, text=~value, type='bar', color=~(year=='2021'),
textposition = 'outside', texttemplate = '%{text:.2s}',
hovertemplate = paste('Year: %{x}', '<br>Value: %{text:.4s}<br><extra></extra>'))
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行提供的 plot_ly 示例,并比较三个柱状条中的 hovertemplate 和 texttemplate,尤其是 2019 年对应的部分。跟踪 R 输入 text、color 和 hovertemplate 如何传递到渲染后的图表中;当 %{text} 为每个柱状条显示预期值时即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100