|
11 | 11 | var parcoords = require('./parcoords');
|
12 | 12 | var prepareRegl = require('../../lib/prepare_regl');
|
13 | 13 |
|
| 14 | +function visible(dimension) { |
| 15 | + return dimension.visible || !('visible' in dimension); |
| 16 | +} |
| 17 | + |
| 18 | +function newIndex(visibleIndices, orig, dim) { |
| 19 | + var origIndex = orig.indexOf(dim); |
| 20 | + var currentIndex = visibleIndices.indexOf(origIndex); |
| 21 | + if(currentIndex === -1) { |
| 22 | + // invisible dimensions initially go to the end |
| 23 | + currentIndex += orig.length; |
| 24 | + } |
| 25 | + return currentIndex; |
| 26 | +} |
| 27 | + |
| 28 | +function sorter(visibleIndices, orig) { |
| 29 | + return function sorter(d1, d2) { |
| 30 | + return ( |
| 31 | + newIndex(visibleIndices, orig, d1) - |
| 32 | + newIndex(visibleIndices, orig, d2) |
| 33 | + ); |
| 34 | + }; |
| 35 | +} |
| 36 | + |
14 | 37 | module.exports = function plot(gd, cdModule) {
|
15 | 38 | var fullLayout = gd._fullLayout;
|
16 | 39 | var svg = fullLayout._toppaper;
|
@@ -83,29 +106,8 @@ module.exports = function plot(gd, cdModule) {
|
83 | 106 | // Have updated order data on `gd.data` and raise `Plotly.restyle` event
|
84 | 107 | // without having to incur heavy UI blocking due to an actual `Plotly.restyle` call
|
85 | 108 |
|
86 |
| - function visible(dimension) {return !('visible' in dimension) || dimension.visible;} |
87 |
| - |
88 |
| - function newIndex(visibleIndices, orig, dim) { |
89 |
| - var origIndex = orig.indexOf(dim); |
90 |
| - var currentIndex = visibleIndices.indexOf(origIndex); |
91 |
| - if(currentIndex === -1) { |
92 |
| - // invisible dimensions initially go to the end |
93 |
| - currentIndex += orig.length; |
94 |
| - } |
95 |
| - return currentIndex; |
96 |
| - } |
97 |
| - |
98 |
| - function sorter(orig) { |
99 |
| - return function sorter(d1, d2) { |
100 |
| - return ( |
101 |
| - newIndex(visibleIndices, orig, d1) - |
102 |
| - newIndex(visibleIndices, orig, d2) |
103 |
| - ); |
104 |
| - }; |
105 |
| - } |
106 |
| - |
107 | 109 | // drag&drop sorting of the visible dimensions
|
108 |
| - var orig = sorter(initialDims[i].filter(visible)); |
| 110 | + var orig = sorter(visibleIndices, initialDims[i].filter(visible)); |
109 | 111 | currentDims[i].sort(orig);
|
110 | 112 |
|
111 | 113 | // invisible dimensions are not interpreted in the context of drag&drop sorting as an invisible dimension
|
|
0 commit comments