Skip to content

Commit 059343f

Browse files
committed
sorting typed arrays OK
1 parent 60360ea commit 059343f

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/lib/sort_traces.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
'use strict';
22

33
function zipArrays(arrays) {
4-
var zipped = arrays[0].map(function(e, i) {
4+
var zipped = [];
5+
arrays[0].forEach(function(e, i) {
56
var row = [];
6-
arrays.map(function(arr) {
7+
arrays.forEach(function(arr) {
78
row.push(arr[i]);
89
});
9-
return row;
10+
zipped.push(row);
1011
});
1112
return zipped;
1213
}

src/plots/cartesian/set_convert.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,12 @@ module.exports = function setConvert(ax, fullLayout) {
388388
for(var k = 0; k < fullData[traceIndices[0]][axLetter].length; k++) {
389389
cols.push('col' + k.toString());
390390
}
391+
if(cols.length < 2) {
392+
return;
393+
}
391394
// Don't think that the trace should be drawn at all if the lengths don't match. Removing the arrays length check. It is better to fail loudly than silently.
392395

396+
debugger;
393397
for(i = 0; i < traceIndices.length; i++) {
394398
var trace = fullData[traceIndices[i]];
395399

@@ -454,17 +458,20 @@ module.exports = function setConvert(ax, fullLayout) {
454458
}
455459
}
456460
}
457-
ax.levelNr = axLabels[0].length;
458-
ax.levels = axLabels[0].map(function(_, idx) {return idx;});
459461

460-
var fullSortedObjectList = sortLib.sortObjectList(cols, fullObjectList.slice());
461-
var fullList = sortLib.objectListToList(fullSortedObjectList);
462-
var fullSortedMatrix = sortLib.sortedMatrix(fullList, true);
462+
if(axLabels.length) {
463+
ax.levelNr = axLabels[0].length;
464+
ax.levels = axLabels[0].map(function(_, idx) {return idx;});
465+
466+
var fullSortedObjectList = sortLib.sortObjectList(cols, fullObjectList.slice());
467+
var fullList = sortLib.objectListToList(fullSortedObjectList);
468+
var fullSortedMatrix = sortLib.sortedMatrix(fullList, true);
463469

464-
var fullXs = fullSortedMatrix[0].slice();
470+
var fullXs = fullSortedMatrix[0].slice();
465471

466-
for(i = 0; i < fullXs.length; i++) {
467-
setCategoryIndex(fullXs[i]);
472+
for(i = 0; i < fullXs.length; i++) {
473+
setCategoryIndex(fullXs[i]);
474+
}
468475
}
469476
};
470477
}

0 commit comments

Comments
 (0)