plotly / plotly/plotly.js

Adding layers makes tooltips disappear

Đang mở
#7,071 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.

bug P3
Ngôn ngữ chính
JavaScript
Star
18.3k
Fork
2k
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
28

Mô tả

Hi there,

I'm experiencing the same issue as @borenstein, referenced here: Adding layer makes tool tips disappear. Someone asked @borenstein to post the issue here but I didn't see a record of it. Here's a shorter reproducible example and summary; please note their solution (comparing data on hover) doesn't work in my use case (not shown here).

I want to create a plot where users can hover over a map and a tooltip for a single layer appears, for example, showing the names of US counties, with state boundaries overlaid on the map. If your mouse is "far" from a state boundary, the tooltip appears. However, if you are "close" (e.g., southeastern edge of map), the tooltip does not appear.

I've tried identifying the traces that contain parts of my plot that I don't want to show tooltips for - as in these stack overflow posts:

But, it doesn't work.

library(plotly)
library(tidyverse)

### New England: *sometimes* shows tool tips
new_england <- c("maine", "new hampshire", "vermont", "massachusetts", "connecticut", "rhode island")

b <- ggplot2::map_data("state") %>%
  filter(region %in% new_england)

a <- data.frame(group = seq(3085), val = rnorm(3085)) %>%
  left_join(ggplot2::map_data("county"), by = "group") %>%
  filter(region %in% new_england)

p <- ggplot(a, aes(long, lat, group = group)) +
  geom_polygon(aes(fill = val, text = subregion)) +
  geom_path(data = b, color = "black")

ggplotly(p, tooltip="text")

image

image

Tagging @MountainCedar so they know I've filed an issue about this.

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 ví dụ ggplotly có thể tái hiện được đã cung cấp và so sánh hành vi hover ở gần và xa ranh giới bang. Theo dõi cách các trace polygon và path xếp lớp xử lý việc chọn tooltip; được xem là hoàn tất khi tooltip tên quận vẫn khả dụng gần ranh giới mà không cần đến workaround được đề xuất. Issue không nêu tên file hoặc test nào, vì vậy việc xác định mã hover liên quan và bổ sung phạm vi kiểm thử hồi quy sẽ đòi hỏi sự quen thuộc với dự án.

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

Đánh giá

Công nghệ
javascript, 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
35/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.