Multi-category sorting misbehaves with missing categories
未关闭
还没有人认领这个 Issue。
bug
P3
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 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});

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).
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用提供的 CodePen 示例和 Plotly.newPlot 配置重现该行为,重点关注某个类别仅出现在后一个组中时多类别轴的排序。将显示的顺序与指定的升序进行比较;当第二个多类别按 1, 2, 3, 4 排序,同时保留示例中报告的行为时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100