plotly / plotly/plotly.js

X-axis type lost after restyle

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

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

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

説明

If i create a bar chart with a categorical x-axis, where the x-values are strings of digits, then restyle it with new y-values, the categoricality of the x-axis is lost, and it becomes linear, as if the type had been freshly inferred from the values.

Here is a self-contained example (i'm afraid i don't have a codepen account):

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Restyle</title>
        <script src="https://cdn.plot.ly/plotly-latest.js"></script>
        <script>
            addEventListener("DOMContentLoaded", () => {
                const plot = document.getElementById("plot");

                Plotly.newPlot(plot,
                               {
                                   data: [{
                                       type: "bar",
                                       x: ["2", "5", "10", "30", "50"],
                                       y: [1, 2, 3, 4, 5]
                                   }],
                                   layout: {
                                       xaxis: {type: "category"}
                                   },
                                   config: {
                                       responsive: true
                                   }
                               });

                document.getElementById("restyle").addEventListener("click", () => {
                    Plotly.restyle(plot, {y: [[5, 4, 3, 2, 1]]}, 0);
                });
            });
        </script>
    </head>
    <body>
        <div id="plot"></div>
        <button id="restyle">Restyle</button>
    </body>
</html>

When the page loads, the x-axis is correctly categorical, but when you click the button, it becomes incorrectly linear.

I believe this is the same problem as described in the forum post "X-axis “category” type not honored after Plotly.restyle".

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

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

はじめの一歩

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

調査の方向性

まず Plotly.newPlot と Plotly.restyle を使った自己完結型の HTML 例を実行し、次に棒グラフを更新する restyle パスを追跡します。y 値を置き換えた後も x 軸がカテゴリのまま維持され、線形として再推論されなければ完了です。

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

評価

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

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

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