Heatmaps with hovertemplate with %{text} is not working
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 18.3k
- Forks
- 2k
- Merge moyen
- 2 j 12 h
- PR mergées (30 j)
- 28
Description
The following works for scatter plot where you can see %{text} is being populated from the provided text:
<head>
<!-- Load plotly.js into the DOM -->
<script src='https://cdn.plot.ly/plotly-2.24.1.min.js'></script>
</head>
<body>
<div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
</body>
var data = [
{
type: 'scatter',
mode: 'lines+markers',
x: [1, 2, 3],
y: [2, 4, 6],
z: [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
hovertemplate: '<i>Price</i>: $%{y:.2f}' +
'<br><b>X</b>: %{x}<br>' +
'<b>%{text}</b>',
text: ["Text A", "Text B", "Text C"],
showlegend: false
}
];
var layout = {
title: "Set hover text with hovertemplate",
};
Plotly.newPlot('myDiv', data, layout);
But the same doesn't work you generate a heatmap (the code is the same, except changed the type to heatmap):
var data = [
{
type: 'heatmap',
mode: 'lines+markers',
x: [1, 2, 3],
y: [2, 4, 6],
z: [[1, 2, 3], [4, 5, 6], [7, 8, 9]],
hovertemplate: '<i>Price</i>: $%{y:.2f}' +
'<br><b>X</b>: %{x}<br>' +
'<b>%{text}</b>',
text: ["Text A", "Text B", "Text C"],
showlegend: false
}
];
var layout = {
title: "Set hover text with hovertemplate",
};
Plotly.newPlot('myDiv', data, layout);
Would really appreciate some help on this.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par exécuter la reproduction HTML et JavaScript fournie avec Plotly 2.24.1, puis comparez la gestion de hovertemplate pour les traces scatter et heatmap. Suivez le comportement du survol de heatmap et son mappage des données %{text} ; c'est terminé lorsque le texte fourni apparaît dans les libellés de survol de heatmap sans régression du comportement de scatter.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100