Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding layers makes tooltips disappear #7071

Open
Nova-Scotia opened this issue Jul 30, 2024 · 1 comment
Open

Adding layers makes tooltips disappear #7071

Nova-Scotia opened this issue Jul 30, 2024 · 1 comment
Labels
bug something broken P3 not needed for current cycle

Comments

@Nova-Scotia
Copy link

Nova-Scotia commented Jul 30, 2024

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.

@borenstein
Copy link

Wow @Nova-Scotia, this is a blast from the past! I actually have not really done much data visualization the last several years.

@gvwilson gvwilson added bug something broken P3 not needed for current cycle labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 not needed for current cycle
Projects
None yet
Development

No branches or pull requests

3 participants