Hover text not visible for small bars
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
I can't find a way to get the hover text to show up in a bar chart when the value of the bar is 0 or very small. The bar is not shown at all when the value is 0 but you can get around that by adding an outline color which makes it visible. However, the hover text does not show. One work around is to replace the zero with a small number but this does not show the hover text unless you zoom in or move the cursor extremely slowly. Another work around which works okay is to add a very small point geom which will provide the hover text for the small bar but then there are two different hover text sources for the larger bars which looks strange.
An ideal solution in my opinion would show a line when the value is 0 and the hover text would show up over the line. This is not the default for ggplot though so it would also be fine if when the line is added by including an outline for the bar geom the hovertext showed up when hovering near the line.
library(ggplot2)
library(plotly)
df <- data.frame(x = letters[1:5], y = 0:4*10, text = paste("some text", 1:5))
# No bar in ggplot or plotly
gp <- ggplot(df, aes(x, y, text = text))+
geom_col()
ggplotly(gp, tooltip = "text")
# has line but no hovertext
gp <- ggplot(df, aes(x, y, text = text))+
geom_col(color = "black")
ggplotly(gp, tooltip = "text")
# has small bar but can only see hover text if zoom in
df$y[1] <- 0.01
gp <- ggplot(df, aes(x, y, text = text))+
geom_col(color = "black")
ggplotly(gp, tooltip = "text")
# Hover text shows up for point but mutiple hovertexts for larger bars
gp <- ggplot(df, aes(x, y, text = text))+
geom_col(color = "black")+
geom_point(size = 0.1)
ggplotly(gp, tooltip = "text")
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行 issue 中的 ggplotly 示例,并追踪 geom_col 柱形如何为零值和非常小的值生成 hover 目标。确定柱形 hover 处理及其相关测试,然后验证零值或非常小值的柱形会显示所请求的 tooltip,而不会创建重复的 hover 源。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100