Skip to content

Commit d13542e

Browse files
committed
sort categories by values: deal with 2dMap in its own conditional block
1 parent bf6bdf3 commit d13542e

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

Diff for: src/plots/plots.js

+17-20
Original file line numberDiff line numberDiff line change
@@ -2927,8 +2927,8 @@ function sortAxisCategoriesByValue(axList, gd) {
29272927
var cdi = cd[k];
29282928
var cat, catIndex, value;
29292929

2930-
// If `splom`, collect values across dimensions
29312930
if(type === 'splom') {
2931+
// If `splom`, collect values across dimensions
29322932
// Find which dimension the current axis is representing
29332933
var currentDimensionIndex = fullTrace._axesDim[ax._id];
29342934

@@ -2950,8 +2950,8 @@ function sortAxisCategoriesByValue(axList, gd) {
29502950
categoriesValue[catIndex][1].push(dimension.values[l]);
29512951
}
29522952
}
2953-
// If `scattergl`, collect all values stashed under cdi.t
29542953
} else if(type === 'scattergl') {
2954+
// If `scattergl`, collect all values stashed under cdi.t
29552955
for(l = 0; l < cdi.t.x.length; l++) {
29562956
if(axLetter === 'x') {
29572957
cat = cdi.t.x[l];
@@ -2971,32 +2971,29 @@ function sortAxisCategoriesByValue(axList, gd) {
29712971
if(cdi.t && cdi.t._scene) {
29722972
delete cdi.t._scene.dirty;
29732973
}
2974-
// For all other 2d cartesian traces
2974+
} else if(cdi.hasOwnProperty('z')) {
2975+
// If 2dMap, collect values in `z`
2976+
value = cdi.z;
2977+
var mapping = zMapCategory(fullTrace.type, ax, value);
2978+
2979+
for(l = 0; l < value.length; l++) {
2980+
for(o = 0; o < value[l].length; o++) {
2981+
catIndex = mapping(o, l);
2982+
if(catIndex + 1) categoriesValue[catIndex][1].push(value[l][o]);
2983+
}
2984+
}
29752985
} else {
2986+
// For all other 2d cartesian traces
29762987
if(axLetter === 'x') {
29772988
cat = cdi.p + 1 ? cdi.p : cdi.x;
29782989
value = cdi.s || cdi.v || cdi.y;
29792990
} else if(axLetter === 'y') {
29802991
cat = cdi.p + 1 ? cdi.p : cdi.y;
29812992
value = cdi.s || cdi.v || cdi.x;
29822993
}
2983-
2984-
// If 2dMap, collect values in `z`
2985-
if(cdi.hasOwnProperty('z')) {
2986-
value = cdi.z;
2987-
var mapping = zMapCategory(fullTrace.type, ax, value);
2988-
2989-
for(l = 0; l < value.length; l++) {
2990-
for(o = 0; o < value[l].length; o++) {
2991-
catIndex = mapping(o, l);
2992-
if(catIndex + 1) categoriesValue[catIndex][1].push(value[l][o]);
2993-
}
2994-
}
2995-
} else {
2996-
if(!Array.isArray(value)) value = [value];
2997-
for(l = 0; l < value.length; l++) {
2998-
categoriesValue[cat][1].push(value[l]);
2999-
}
2994+
if(!Array.isArray(value)) value = [value];
2995+
for(l = 0; l < value.length; l++) {
2996+
categoriesValue[cat][1].push(value[l]);
30002997
}
30012998
}
30022999
}

0 commit comments

Comments
 (0)