Skip to content

Commit 21ab834

Browse files
authored
Merge pull request #2065 from plotly/gup-utils-rollout
Roll out General Update Pattern utils to `parcoords` and `sankey`
2 parents 675150f + bc18893 commit 21ab834

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

src/traces/parcoords/calc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
var hasColorscale = require('../../components/colorscale/has_colorscale');
1212
var calcColorscale = require('../../components/colorscale/calc');
1313
var Lib = require('../../lib');
14-
14+
var wrap = require('../../lib/gup').wrap;
1515

1616
module.exports = function calc(gd, trace) {
1717
var cs = !!trace.line.colorscale && Lib.isArray(trace.line.color);
@@ -22,8 +22,8 @@ module.exports = function calc(gd, trace) {
2222
calcColorscale(trace, trace.line.color, 'line', 'c');
2323
}
2424

25-
return [{
25+
return wrap({
2626
lineColor: color,
2727
cscale: cscale
28-
}];
28+
});
2929
};

src/traces/parcoords/parcoords.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ var c = require('./constants');
1313
var Lib = require('../../lib');
1414
var d3 = require('d3');
1515
var Drawing = require('../../components/drawing');
16-
17-
function keyFun(d) {return d.key;}
18-
19-
function repeat(d) {return [d];}
16+
var keyFun = require('../../lib/gup').keyFun;
17+
var repeat = require('../../lib/gup').repeat;
18+
var unwrap = require('../../lib/gup').unwrap;
2019

2120
function visible(dimension) {return !('visible' in dimension) || dimension.visible;}
2221

@@ -126,10 +125,6 @@ function unitToColorScale(cscale) {
126125
};
127126
}
128127

129-
function unwrap(d) {
130-
return d[0]; // plotly data structure convention
131-
}
132-
133128
function model(layout, d, i) {
134129
var cd0 = unwrap(d),
135130
trace = cd0.trace,

src/traces/sankey/calc.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
var tarjan = require('strongly-connected-components');
1212
var Lib = require('../../lib');
13+
var wrap = require('../../lib/gup').wrap;
1314

1415
function circularityPresent(nodeList, sources, targets) {
1516

@@ -44,8 +45,8 @@ module.exports = function calc(gd, trace) {
4445
trace.node.color = [];
4546
}
4647

47-
return [{
48+
return wrap({
4849
link: trace.link,
4950
node: trace.node
50-
}];
51+
});
5152
};

src/traces/sankey/render.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ var Drawing = require('../../components/drawing');
1616
var d3sankey = require('@plotly/d3-sankey').sankey;
1717
var d3Force = require('d3-force');
1818
var Lib = require('../../lib');
19+
var keyFun = require('../../lib/gup').keyFun;
20+
var repeat = require('../../lib/gup').repeat;
21+
var unwrap = require('../../lib/gup').unwrap;
1922

2023
// basic data utilities
2124

22-
function keyFun(d) {return d.key;}
23-
function repeat(d) {return [d];} // d3 data binding convention
24-
function unwrap(d) {return d[0];} // plotly data structure convention
25-
2625
function persistOriginalPlace(nodes) {
2726
var i, distinctLayerPositions = [];
2827
for(i = 0; i < nodes.length; i++) {

0 commit comments

Comments
 (0)