plotly / plotly/plotly.js

Multi-category sorting misbehaves with missing categories

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

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

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

説明

Originally reported in https://github.com/plotly/plotly.py/issues/1491.

There seems to a multi-category sorting bug that wasn't fixed by #3362.

CodePen: https://codepen.io/jonmmease/pen/VNeEqq?editors=1010

var fig = {
  "data": [
    {
      "name": "Fruits",
      "type": "bar",
      "x": [
        [
          2017,
          2017,
          2017,
          2017,
          2017,
          2017,
          2017,
          2017,
          2018,
          2018,
          2018,
          2018
        ],
        [
          4,
          5,
          6,
          8,
          9,
          10,
          11,
          12,
          1,
          2,
          3,
          4
        ]
      ],
      "y": [
        57246.0,
        1587.0,
        63189.0,
        30680.0,
        26071.0,
        117519.0,
        27519.0,
        42643.0,
        8559.0,
        22355.0,
        59363.0,
        62955.0
      ]
    },
    {
      "name": "Price",
      "type": "scatter",
      "x": [
        [
          2017,
          2017,
          2017,
          2017,
          2017,
          2017,
          2017,
          2017,
          2018,
          2018,
          2018,
          2018
        ],
        [
          4,
          5,
          6,
          8,
          9,
          10,
          11,
          12,
          1,
          2,
          3,
          4
        ]
      ],
      "y": [
        0.22991999,
        0.27284184,
        0.18438336,
        0.24866362,
        0.18280848,
        0.19382398,
        0.17268069,
        0.18802617,
        0.17560463,
        0.13415343,
        0.14773512,
        0.31319196
      ],
      "yaxis": "y2"
    }
  ],
  "layout": {
    "height": 600,
    "showlegend": true,
    "yaxis": {
      "showgrid": true,
      "title": {
        "text": "Fruits volume"
      }
    },
    "yaxis2": {
      "anchor": "x",
      "overlaying": "y",
      "showgrid": false,
      "side": "right",
      "title": {
        "text": "Price per unit"
      }
    }
  }
}

Plotly.newPlot('myDiv', fig, {showSendToCloud: true});

newplot-8

The problem is that in the second multi-category (2018), the 4 is sorted before 1, 2, 3 even though they are specified in ascending sorted order.

As noted in https://github.com/plotly/plotly.py/issues/1491, this seems to happen for categories that are not present in the first multi-category (2017).

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

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

はじめの一歩

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

調査の方向性

提供されたCodePenの例とPlotly.newPlotの設定を使用して挙動を再現し、カテゴリが後のグループにのみ存在する場合の複数カテゴリ軸の並べ替えに焦点を当てます。表示された順序を指定された昇順と比較します。完了条件は、2つ目の複数カテゴリが1, 2, 3, 4の順に並べ替えられ、例で報告されている挙動が維持されることです。

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

評価

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

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

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