plotly / plotly/plotly.R

Hover text not visible for small bars

Offen
#2,114 1 Kommentar 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

I can't find a way to get the hover text to show up in a bar chart when the value of the bar is 0 or very small. The bar is not shown at all when the value is 0 but you can get around that by adding an outline color which makes it visible. However, the hover text does not show. One work around is to replace the zero with a small number but this does not show the hover text unless you zoom in or move the cursor extremely slowly. Another work around which works okay is to add a very small point geom which will provide the hover text for the small bar but then there are two different hover text sources for the larger bars which looks strange.

An ideal solution in my opinion would show a line when the value is 0 and the hover text would show up over the line. This is not the default for ggplot though so it would also be fine if when the line is added by including an outline for the bar geom the hovertext showed up when hovering near the line.

library(ggplot2)
library(plotly)

df <- data.frame(x = letters[1:5], y = 0:4*10, text = paste("some text", 1:5))

# No bar in ggplot or plotly
gp <- ggplot(df, aes(x, y, text = text))+
  geom_col()

ggplotly(gp, tooltip = "text")

# has line but no hovertext
gp <- ggplot(df, aes(x, y, text = text))+
  geom_col(color = "black")

ggplotly(gp, tooltip = "text")

# has small bar but can only see hover text if zoom in
df$y[1] <- 0.01

gp <- ggplot(df, aes(x, y, text = text))+
  geom_col(color = "black")

ggplotly(gp, tooltip = "text")

# Hover text shows up for point but mutiple hovertexts for larger bars
gp <- ggplot(df, aes(x, y, text = text))+
  geom_col(color = "black")+
  geom_point(size = 0.1)

ggplotly(gp, tooltip = "text")

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 ggplotly-Beispiele im Issue auszuführen und nachzuverfolgen, wie geom_col-Balken Hover-Ziele für null und sehr kleine Werte erzeugen. Identifiziere die Hover-Behandlung von Balken und die zugehörigen Tests und überprüfe anschließend, dass Balken mit dem Wert null oder sehr kleinen Werten den angeforderten Tooltip anzeigen, ohne doppelte Hover-Quellen zu erzeugen.

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
30/100

Neue Issues direkt in Ihr Postfach

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