Skip to content

No unwarranted colorscale or related data on parcoords trace/fullTrace #1508

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 3 commits into from
Mar 22, 2017

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Mar 21, 2017

Avoid color scale persistence on trace / fullTrace if the user hasn't specified one (as interpreted by has_colorscale.js)

Before this PR, colorscale related details populated data and fullData, as seen by these test case changes.

… specified one (as interpreted by has_colorscale.js)
@monfera monfera added status: reviewable bug something broken labels Mar 21, 2017
@monfera monfera self-assigned this Mar 21, 2017
var cs = !!trace.line.colorscale && Lib.isArray(trace.line.color);
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;});
var cscale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just moved this block unchanged from here, where it'd be persisted, to parcoords.js below, as this calculation is now considered implementation detail, unexposed on data/fullData

var cscale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]];

trace.line.color = color;
trace.line.colorscale = cscale;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... so, no more persisting

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;});
var lineColorScale = cs ? trace.line.colorscale : [[0, trace.line.color], [1, trace.line.color]];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay this is the moved logic block

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. I would prefer not. Per-datum non-pixel related computations should be in the calc step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the original code, calc.js actually persisted the result of these calculations, see above, these lines:

-    trace.line.color = color;
-    trace.line.colorscale = cscale;

... so instead of this, I'd just return these two derived things (whereas now, calc.js returns {})
Is it how you'd prefer it? I'm swamped with preparation so I'd avoid dead-ends and you may already have a preferred way in mind (or see issues with it).


if(hasColorscale(traceIn, 'line')) {
if(hasColorscale(traceIn, 'line') && Lib.isArray(traceIn.line.color)) {
coerce('line.colorscale');
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no point in attempting to use a color scale if line.color is not an array but e.g. a plain color, because the line.color numerical array values are mapped to the colors on the color scale.
Also, now line.colorscale is only performed if it's warranted.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe patching defaults.js is all you need to fix this bug.

- but store results in calcdata items, instead of mutating
  the corresponding fullData items.
Edits for no unwarranted colorscale or related data on parcoords trace/fullTrace
Copy link
Contributor

@etpinard etpinard left a comment

Choose a reason for hiding this comment

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

good to merge 💃

@monfera monfera merged commit 8ad7e93 into master Mar 22, 2017
@etpinard etpinard deleted the parcoords-avoid-colorscale branch March 24, 2017 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants