plotly / plotly/plotly.js

Adding layers makes tooltips disappear

Offen
#7,071 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3
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:

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Ö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

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.