Skip to content

Commit a6ca31d

Browse files
committed
moving gd[].dimensions out of parcoords.js plotly#3
1 parent 9da2be6 commit a6ca31d

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/traces/parcoords/parcoords.js

+1-19
Original file line numberDiff line numberDiff line change
@@ -508,26 +508,8 @@ module.exports = function(root, svg, styledData, layout, callbacks) {
508508
p.pickLineLayer && p.pickLineLayer.render(p.panels, true);
509509
linePickActive = true;
510510

511-
function newIdx(orig, dim) {
512-
var origIndex = orig.indexOf(dim);
513-
var currentIndex = p.dimensions.map(function(dd) {return dd.crossfilterDimensionIndex;}).indexOf(origIndex);
514-
if(currentIndex === -1) {
515-
// invisible dimensions go to the end, retaining their original order
516-
currentIndex += orig.length;
517-
}
518-
return currentIndex;
519-
}
520-
521-
function sorter(orig) {
522-
return function sorter(d1, d2) {
523-
var i1 = newIdx(orig, d1);
524-
var i2 = newIdx(orig, d2);
525-
return i1 - i2;
526-
};
527-
}
528-
529511
if(callbacks && callbacks.axesMoved) {
530-
callbacks.axesMoved(p.key, sorter);
512+
callbacks.axesMoved(p.key, p.dimensions.map(function(dd) {return dd.crossfilterDimensionIndex;}));
531513
}
532514
})
533515
);

src/traces/parcoords/plot.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,29 @@ module.exports = function plot(gd, cdparcoords) {
5050
gd.emit('plotly_unhover', eventData);
5151
};
5252

53-
var axesMoved = function(i, sorter) {
53+
var axesMoved = function(i, visibleIndices) {
5454

5555
// Have updated order data on `gd.data` and raise `Plotly.restyle` event
5656
// without having to incur heavy UI blocking due to an actual `Plotly.restyle` call
5757

58+
function newIdx(visibleIndices, orig, dim) {
59+
var origIndex = orig.indexOf(dim);
60+
var currentIndex = visibleIndices.indexOf(origIndex);
61+
if(currentIndex === -1) {
62+
// invisible dimensions go to the end, retaining their original order
63+
currentIndex += orig.length;
64+
}
65+
return currentIndex;
66+
}
67+
68+
function sorter(orig) {
69+
return function sorter(d1, d2) {
70+
var i1 = newIdx(visibleIndices, orig, d1);
71+
var i2 = newIdx(visibleIndices, orig, d2);
72+
return i1 - i2;
73+
};
74+
}
75+
5876
var orig = sorter(gdDimensionsOriginalOrder[i].filter(function(d) {return d.visible === void(0) || d.visible;}));
5977
gdDimensions[i].sort(orig);
6078

0 commit comments

Comments
 (0)