plotly / plotly/plotly.R

hovertemplate not parsed with text input

Aperta
#2,036 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
R
Stelle
2.7k
Fork
641
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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>'))

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo l’esempio plot_ly fornito e confronta hovertemplate con texttemplate su tutte e tre le barre, in particolare il segmento del 2019. Traccia il modo in cui gli input R text, color e hovertemplate vengono passati al grafico renderizzato; il lavoro è completato quando %{text} visualizza il valore previsto per ogni barra.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
r
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.