Adding layers makes tooltips disappear
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 18.3k
- Forks
- 2k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 28
Beschreibung
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:
-
ggplotly - only return tooltip hover text on certain geom objects
-
Disable hover information for a specific layer (geom) of plotly
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")
Tagging @MountainCedar so they know I've filed an issue about this.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Führe zunächst das bereitgestellte ggplotly-reproduzierbare Beispiel aus und vergleiche das Hover-Verhalten in der Nähe und in größerer Entfernung von der Staatsgrenze. Verfolge, wie geschichtete Polygon- und Pfad-Traces die Tooltip-Auswahl behandeln; als erledigt gilt die Aufgabe, wenn Tooltips mit County-Namen in der Nähe von Grenzen verfügbar bleiben, ohne den vorgeschlagenen Workaround zu erfordern. Im Issue wird weder eine Datei noch ein Test genannt, daher erfordert das Auffinden des relevanten Hover-Codes und das Hinzufügen einer Regressionstestabdeckung Vertrautheit mit dem Projekt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, r
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100