Skip to content

Commit 8ad7e93

Browse files
authored
Merge pull request #1508 from plotly/parcoords-avoid-colorscale
No unwarranted colorscale or related data on parcoords trace/fullTrace
2 parents c753e47 + 8b4124a commit 8ad7e93

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

src/traces/parcoords/calc.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ module.exports = function calc(gd, trace) {
1818
var color = cs ? trace.line.color : Array.apply(0, Array(trace.dimensions.reduce(function(p, n) {return Math.max(p, n.values.length);}, 0))).map(function() {return 0.5;});
1919
var cscale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]];
2020

21-
trace.line.color = color;
22-
trace.line.colorscale = cscale;
23-
2421
if(hasColorscale(trace, 'line')) {
2522
calcColorscale(trace, trace.line.color, 'line', 'c');
2623
}
2724

28-
return [{}];
25+
return [{
26+
lineColor: color,
27+
cscale: cscale
28+
}];
2929
};

src/traces/parcoords/defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ var maxDimensionCount = require('./constants').maxDimensionCount;
1717
function handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
1818

1919
coerce('line.color', defaultColor);
20-
coerce('line.colorscale');
2120

22-
if(hasColorscale(traceIn, 'line')) {
21+
if(hasColorscale(traceIn, 'line') && Lib.isArray(traceIn.line.color)) {
22+
coerce('line.colorscale');
2323
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'});
2424
}
2525
else {

src/traces/parcoords/parcoords.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,17 @@ function unwrap(d) {
115115
}
116116

117117
function model(layout, d, i) {
118-
var trace = unwrap(d).trace,
118+
var cd0 = unwrap(d),
119+
trace = cd0.trace,
120+
lineColor = cd0.lineColor,
121+
cscale = cd0.cscale,
119122
line = trace.line,
120123
domain = trace.domain,
121124
dimensions = trace.dimensions,
122125
width = layout.width;
123126

124127
var lines = Lib.extendDeep({}, line, {
125-
color: line.color.map(domainToUnitScale({values: line.color, range: [line.cmin, line.cmax]})),
128+
color: lineColor.map(domainToUnitScale({values: lineColor, range: [line.cmin, line.cmax]})),
126129
blockLineCount: c.blockLineCount,
127130
canvasOverdrag: c.overdrag * c.canvasPixelRatio
128131
});
@@ -139,7 +142,7 @@ function model(layout, d, i) {
139142
colCount: dimensions.filter(visible).length,
140143
dimensions: dimensions,
141144
tickDistance: c.tickDistance,
142-
unitToColor: unitToColorScale(line.colorscale),
145+
unitToColor: unitToColorScale(cscale),
143146
lines: lines,
144147
translateX: domain.x[0] * width,
145148
translateY: layout.height - domain.y[1] * layout.height,

test/jasmine/tests/parcoords_test.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,11 @@ describe('parcoords initialization tests', function() {
197197
}));
198198

199199
expect(fullTrace.line).toEqual({
200-
color: [0.5, 0.5, 0.5, 0.5],
201-
colorscale: [[0, '#444'], [1, '#444']],
202-
cmin: 0,
203-
cmax: 1
200+
color: '#444'
204201
});
205202
});
206203

207-
it('use a singular \'color\' even if a \'colorscale\' is supplied', function() {
204+
it('use a singular \'color\' even if a \'colorscale\' is supplied as \'color\' is not an array', function() {
208205

209206
var fullTrace = _calc(Lib.extendDeep({}, base, {
210207
line: {
@@ -218,14 +215,7 @@ describe('parcoords initialization tests', function() {
218215
}));
219216

220217
expect(fullTrace.line).toEqual({
221-
color: [0.5, 0.5, 0.5, 0.5],
222-
colorscale: [[0, '#444'], [1, '#444']],
223-
autocolorscale: false,
224-
showscale: false,
225-
reversescale: false,
226-
cauto: true,
227-
cmin: 0,
228-
cmax: 1
218+
color: '#444'
229219
});
230220
});
231221
});

0 commit comments

Comments
 (0)