plotly / plotly/plotly.js

Heatmaps with hovertemplate with %{text} is not working

オープン
#6,689 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
JavaScript
スター
18.3k
フォーク
2k
平均マージ
2日 12時間
マージ済み PR(30日)
28

説明

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);
Screenshot 2023-07-27 at 2 42 53 PM

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

Screenshot 2023-07-27 at 2 45 52 PM

Would really appreciate some help on this.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された HTML および JavaScript の再現コードを Plotly 2.24.1 で実行し、scatter と heatmap の trace に対する hovertemplate の処理を比較します。heatmap の hover 動作とその %{text} データマッピングを追跡します。提供されたテキストが heatmap の hover ラベルに表示され、scatter の動作にリグレッションがないことを確認できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。