plotly / plotly/plotly.js

Adding layers makes tooltips disappear

Open
#7,071 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided ggplotly reproducible example and compare hover behavior near and far from the state boundary. Trace how layered polygon and path traces handle tooltip selection; done means county-name tooltips remain available near boundaries without requiring the proposed workaround. No file or test is named in the issue, so locating the relevant hover code and adding regression coverage will require project familiarity.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.