plotly / plotly/plotly.R

Hover text not visible for small bars

Đang mở
#2,114 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
R
Star
2.7k
Fork
641
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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")

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy các ví dụ ggplotly trong issue và lần theo cách các thanh geom_col tạo ra các mục tiêu hover cho các giá trị bằng không và rất nhỏ. Xác định phần xử lý hover của thanh và các bài kiểm thử liên quan, sau đó xác minh rằng các thanh có giá trị bằng không hoặc rất nhỏ hiển thị tooltip được yêu cầu mà không tạo ra các nguồn hover trùng lặp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
r
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.