8000 sort categories by values: handle different box orientations · maun/plotly.js@fc1bbce · GitHub
[go: up one dir, main page]

Skip to content

Commit fc1bbce

Browse files
committed
sort categories by values: handle different box orientations
1 parent 75e5556 commit fc1bbce

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/plots/plots.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,7 @@ function sortAxisCategoriesByValue(axList, gd) {
28902890
var cdi = cd[k];
28912891
var cat, catIndex, value;
28922892

2893-
// Collect values across dimensions
2893+
// If `splom`, collect values across dimensions
28942894
if(type === 'splom') {
28952895
// Find which dimension the current axis is representing
28962896
var currentDimensionIndex = cdi.trace[ax._id.charAt(0) + 'axes'].indexOf(ax._id);
@@ -2907,6 +2907,7 @@ function sortAxisCategoriesByValue(axList, gd) {
29072907
categoriesValue[catIndex][1].push(dimension.values[l]);
29082908
}
29092909
}
2910+
// If `scattergl`, collect all values stashed under cdi.t
29102911
} else if(type === 'scattergl') {
29112912
for(l = 0; l < cdi.t.x.length; l++) {
29122913
if(ax._id.charAt(0) === 'x') {
@@ -2927,6 +2928,7 @@ function sortAxisCategoriesByValue(axList, gd) {
29272928
if(cdi.t && cdi.t._scene) {
29282929
delete cdi.t._scene.dirty;
29292930
}
2931+
// For all other 2d cartesian traces
29302932
} else {
29312933
if(ax._id.charAt(0) === 'x') {
29322934
cat = cdi.p + 1 ? cdi.p : cdi.x;
@@ -2936,6 +2938,7 @@ function sortAxisCategoriesByValue(axList, gd) {
29362938
value = cdi.s || cdi.v || cdi.x;
29372939
}
29382940

2941+
// If 2dMap, collect values in `z`
29392942
if(cdi.hasOwnProperty('z')) {
29402943
value = cdi.z;
29412944

@@ -2946,11 +2949,6 @@ function sortAxisCategoriesByValue(axList, gd) {
29462949
}
29472950
}
29482951
} else {
2949-
if(fullData.orientation === 'h') {
2950-
cat = cdi.p + 1 ? cdi.p : cdi.x;
2951-
value = cdi.s || cdi.v || cdi.y;
2952-
}
2953-
29542952
if(!Array.isArray(value)) value = [value];
29552953
for(l = 0; l < value.length; l++) {
29562954
categoriesValue[cat][1].push(value[l]);

src/traces/box/calc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ module.exports = function calc(gd, trace) {
8080
cdi.pos = posDistinct[i];
8181
cdi.pts = pts;
8282

83-
cdi.x = cdi.pos;
84-
cdi.y = cdi.pts.map(function(pt) { return pt.v; });
83+
// Sort categories by values
84+
cdi[posLetter] = cdi.pos;
85+
cdi[valLetter] = cdi.pts.map(function(pt) { return pt.v; });
8586

8687
cdi.min = boxVals[0];
8788
cdi.max = boxVals[bvLen - 1];

0 commit comments

Comments
 (0)
0