Skip to content

Commit fac239b

Browse files
committed
sort categories by values: improve splom logic
1 parent 76683ba commit fac239b

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

src/plots/cartesian/type_defaults.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,8 @@ function setAutoType(ax, data) {
8080
ax.type = autoType(boxPositions, calendar, opts);
8181
} else if(d0.type === 'splom') {
8282
var dimensions = d0.dimensions;
83-
var diag = d0._diag;
84-
for(i = 0; i < dimensions.length; i++) {
85-
var dim = dimensions[i];
86-
if(dim.visible && (diag[i][0] === id || diag[i][1] === id)) {
87-
ax.type = autoType(dim.values, calendar, opts);
88-
break;
89-
}
90-
}
83+
var dim = dimensions[d0._axesDim[id]];
84+
if(dim.visible) ax.type = autoType(dim.values, calendar, opts);
9185
} else {
9286
ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts);
9387
}

src/plots/plots.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,22 +2919,20 @@ function sortAxisCategoriesByValue(axList, gd) {
29192919
// If `splom`, collect values across dimensions
29202920
if(type === 'splom') {
29212921
// Find which dimension the current axis is representing
2922-
var currentDimensionIndex = cdi.trace[axLetter + 'axes'].indexOf(ax._id);
2922+
var currentDimensionIndex = fullTrace._axesDim[ax._id];
29232923

29242924
// Apply logic to associated x axis
29252925
if(axLetter === 'y') {
2926-
var associatedXAxis = ax._id.split('');
2927-
associatedXAxis[0] = 'x';
2928-
associatedXAxis = associatedXAxis.join('');
2929-
ax = gd._fullLayout[axisIDs.id2name(associatedXAxis)];
2926+
var associatedXAxisID = fullTrace._diag[currentDimensionIndex][0];
2927+
ax = gd._fullLayout[axisIDs.id2name(associatedXAxisID)];
29302928
}
29312929

29322930
var categories = cdi.trace.dimensions[currentDimensionIndex].values;
29332931
for(l = 0; l < categories.length; l++) {
29342932
cat = categories[l];
29352933
catIndex = ax._categoriesMap[cat];
29362934

2937-
// Collect values over all other dimensions
2935+
// Collect associated values at index `l` over all other dimensions
29382936
for(o = 0; o < cdi.trace.dimensions.length; o++) {
29392937
if(o === currentDimensionIndex) continue;
29402938
var dimension = cdi.trace.dimensions[o];

src/traces/splom/defaults.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
127127
var mustShiftX = !showDiag && !showLower;
128128
var mustShiftY = !showDiag && !showUpper;
129129

130+
traceOut._axesDim = {};
130131
for(i = 0; i < dimLength; i++) {
131132
var dim = dimensions[i];
132133
var i0 = i === 0;
@@ -143,6 +144,8 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
143144
fillAxisStashes(xaId, yaId, dim, xList);
144145
fillAxisStashes(yaId, xaId, dim, yList);
145146
diag[i] = [xaId, yaId];
147+
traceOut._axesDim[xaId] = i;
148+
traceOut._axesDim[yaId] = i;
146149
}
147150

148151
// fill in splom subplot keys

0 commit comments

Comments
 (0)