plotly / plotly/plotly.R

hovertemplate not parsed with text input

Offen
#2,036 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

Hello plotly.R,

I'm using the hovertemplate in a bar chart with my data segmented using the color argument. I wish to use the text value in my hovertemplate.
The issue is that the template is not processed for one of my two segments.

Run the below code, and hover on the three bars. For the first two, the hover info is correct, for the last one, it shows the template part where the text is supposed to go.

Note 1: replacing text with y works in this case. But there could be a case where I really need the text and not the y.
Note 2: the texttemplate does not have this issue and correctly shows the value of the text in all three bars.

library(plotly)

df <- data.frame(year = c('2021', '2020', '2019'), value = c(123, 110, 95))
plot_ly(data = df, x=~year, y=~value, text=~value, type='bar', color=~(year=='2021'),
        textposition = 'outside', texttemplate = '%{text:.2s}',
        hovertemplate = paste('Year: %{x}', '<br>Value: %{text:.4s}<br><extra></extra>'))

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, das bereitgestellte plot_ly-Beispiel auszuführen, und vergleiche hovertemplate mit texttemplate über alle drei Balken hinweg, insbesondere das Segment für 2019. Verfolge, wie die R-Eingaben text, color und hovertemplate an das gerenderte Diagramm übergeben werden; als erledigt gilt die Aufgabe, wenn %{text} für jeden Balken den erwarteten Wert anzeigt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 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.