Heatmaps with hovertemplate with %{text} is not working
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 18.3k
- Forks
- 2k
- Ø Merge
- 2 T. 12 Std.
- Gemergte PRs (30 T.)
- 28
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die bereitgestellte HTML- und JavaScript-Reproduktion mit Plotly 2.24.1 auszuführen, und vergleiche anschließend die Handhabung von hovertemplate für die scatter- und heatmap-Traces. Verfolge das Hover-Verhalten der heatmap und dessen %{text}-Datenzuordnung; als erledigt gilt die Aufgabe, wenn der bereitgestellte Text in den heatmap-Hover-Beschriftungen erscheint, ohne das Verhalten von scatter zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100