Skip to content

Parcoords coloraxis #3901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/traces/parcoords/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports = {
line: extendFlat({editType: 'calc'},
colorScaleAttrs('line', {
// the default autocolorscale isn't quite usable for parcoords due to context ambiguity around 0 (grey, off-white)
// autocolorscale therefore defaults to false too, to avoid being overridden by the blue-white-red autocolor palette
// autocolorscale therefore defaults to false too, to avoid being overridden by the blue-white-red autocolor palette
colorscaleDflt: 'Viridis',
autoColorDflt: false,
editTypeOverride: 'calc'
Expand Down
27 changes: 14 additions & 13 deletions src/traces/parcoords/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

'use strict';

var hasColorscale = require('../../components/colorscale/helpers').hasColorscale;
var calcColorscale = require('../../components/colorscale/calc');
var Colorscale = require('../../components/colorscale');
var Lib = require('../../lib');
var wrap = require('../../lib/gup').wrap;

Expand All @@ -19,22 +18,24 @@ module.exports = function calc(gd, trace) {
}
trace.line.color = convertTypedArray(trace.line.color);

var cs = !!trace.line.colorscale && Array.isArray(trace.line.color);
var color = cs ? trace.line.color : constHalf(trace._length);
var cscale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]];
var lineColor;
var cscale;

if(hasColorscale(trace, 'line')) {
calcColorscale(gd, trace, {
vals: color,
if(Colorscale.hasColorscale(trace, 'line') && Array.isArray(trace.line.color)) {
lineColor = trace.line.color;
cscale = Colorscale.extractOpts(trace.line).colorscale;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking but cScale may be a better naming.


Colorscale.calc(gd, trace, {
vals: lineColor,
containerStr: 'line',
cLetter: 'c'
});
} else {
lineColor = constHalf(trace._length);
cscale = [[0, trace.line.color], [1, trace.line.color]];
}

return wrap({
lineColor: color,
cscale: cscale
});
return wrap({lineColor: lineColor, cscale: cscale});
};

function constHalf(len) {
Expand All @@ -46,5 +47,5 @@ function constHalf(len) {
}

function convertTypedArray(a) {
return (Lib.isTypedArray(a)) ? Array.prototype.slice.call(a) : a;
return Lib.isTypedArray(a) ? Array.prototype.slice.call(a) : a;
}
5 changes: 3 additions & 2 deletions src/traces/parcoords/parcoords.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ function model(layout, d, i) {
var trace = cd0.trace;
var lineColor = cd0.lineColor;
var line = trace.line;
var cscale = line.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale;
var cOpts = Colorscale.extractOpts(line);
var cscale = cOpts.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale;
var domain = trace.domain;
var dimensions = trace.dimensions;
var width = layout.width;
Expand All @@ -143,7 +144,7 @@ function model(layout, d, i) {
var lines = Lib.extendDeepNoArrays({}, line, {
color: lineColor.map(d3.scale.linear().domain(dimensionExtent({
values: lineColor,
range: [line.cmin, line.cmax],
range: [cOpts.min, cOpts.max],
_length: trace._length
}))),
blockLineCount: c.blockLineCount,
Expand Down
Binary file added test/image/baselines/gl2d_parcoords_coloraxis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading