hovertemplate not rendering text for single items in the plot
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
When using hovertemplate in bar charts to annotate bars,
if the variable is present only once then text annotation doesn't work
For example in below image, Type B is only present once
and when hovered on it shows as "%{text}

but when using hoverinfo it seems to work fine

I need to use hovertemplate, as i had to use it in a function, where color and text options are passed as variable
any workaround to fix this?
Reproducible code example
library(data.table)
library(plotly)
data <- data.table(Date = c(rep(as.Date("2022-10-18"), 3),
rep(as.Date("2022-10-19"), 3),
rep(as.Date("2022-10-20"), 3)),
Type = c('A', 'B', 'C', 'A', 'D', 'C', 'C', 'D', 'A'),
Frequency = c(6, 3, 6, 10, 9, 9, 9, 3, 2))
# hovertemplate - Type B is only one entry and it shows as %{text}
plot_ly(data, x=~Date, y=~Frequency, color=~Type, type='bar', text=~Type,
hovertemplate=paste('<b>%{text}</b>',
'<br><b>%{y}</b>',
'<br><b>%{x}</b>',
'<extra></extra>')) %>%
layout(barmode="stack")
# hoverinfo - works as expected
plot_ly(data, x=~Date, y=~Frequency, color=~Type, type='bar',
hoverinfo = 'text',
text = ~paste('<b>', Type, '</b>',
'<br><b>', Date, '</b>',
'<br><b>', Frequency, '</b>')) %>%
layout(barmode="stack")
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Ejecute el ejemplo reproducible en R del issue y compare las salidas de hovertemplate y hoverinfo, centrándose en la única barra Type B. Rastree la ruta de renderizado de Plotly utilizada por el paquete de R; estará terminado cuando hovertemplate muestre el texto Type B en lugar del literal %{text}.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- plotly, r
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100