plotly / plotly/plotly.R

Tooltip of ggplotly's geom_area not updating along the x axis

Offen
#2,270 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
R
Sterne
2.7k
Forks
641
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Recently, the hover text/tooltip when using geom_area() only shows the values for the first element along the x axis - in the example below, the geom_col graph has the expected tooltips, but the geom_area is stuck with the first value.

library(tidyverse)
economics %>% {ggplot(., aes(x=date,y=pop)) + geom_area()} %>% plotly::ggplotly()
economics %>% {ggplot(., aes(x=date,y=pop)) + geom_col()} %>% plotly::ggplotly()

The problem seems to be in ggplotly() as the native plot_ly() approach still works as expected:

plotly::plot_ly(x=~economics$date, y=~economics$pop, type='scatter', mode='none', stackgroup='one')

In a more complicated graph (with fill groups and facets) other elements seem to update, but the x and y values are stick at the first element still - again, compare geom_area to geom_col results:

economics_status <- economics %>% mutate(pop = pop - unemploy) %>% pivot_longer(cols = c(pop,unemploy), names_to="status", values_to="number")

economics_status %>% 
    {ggplot(., aes(x=date,y=number, fill=status)) + geom_area()} %>% plotly::ggplotly()

economics_status %>% 
    {ggplot(., aes(x=date,y=number, fill=status)) + geom_col()} %>% plotly::ggplotly()

I'm getting the error using R 4.2.2, plotly version 4.10.1. Rolling back using devtools, I am getting the same error back to plotly 4.9.4 - but anything earlier won't load any output at all, so presumably clashing with something else in the ecosystem. It may be relevant that htmlwidgets is at 1.6.2 and htmltools is 0.5.5.

However, all worked fine with R 4.1.3 and plotly 4.10.0 ... which had htmlwidgets at 1.5.4 and htmltools at 0.5.3. But rolling back htmlwidgets with the other settings above does not fix things.

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

Beginne damit, die Wirtschaftsbeispiele über ggplotly() zu reproduzieren, und vergleiche geom_area() mit geom_col() sowie den nativen plot_ly()-Ansatz. Verfolge die Konvertierung von geom_area() und die Verarbeitung der Tooltip-Daten; abgeschlossen ist die Aufgabe, wenn sich die x- und y-Werte bei einfachen, ausgefüllten und facettierten Flächendiagrammen entlang der Achse aktualisieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
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
42/100

Neue Issues direkt in Ihr Postfach

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