Skip to content

Make restyling arrayOk attribute redo calcdata#1488

Merged
etpinard merged 1 commit into
masterfrom
restyle-docalc
Mar 16, 2017
Merged

Make restyling arrayOk attribute redo calcdata#1488
etpinard merged 1 commit into
masterfrom
restyle-docalc

Conversation

@etpinard
Copy link
Copy Markdown
Contributor

fixes #1480

I made a blunder in #1257 where conversion of arrayOk attributes from fullData -> calcdata was moved from the plot step to the calc. I tested restyle, it worked (in some situations) but for the wrong reason. Luckily the fixed wasn't too hard.

I wouldn't mind a @alexcjohnson review.

@etpinard etpinard added status: reviewable bug something broken labels Mar 16, 2017
@etpinard etpinard added this to the v1.25.0 milestone Mar 16, 2017
Comment thread src/plot_api/plot_api.js
var valObject = Lib.nestedProperty(moduleAttrs, ai).get() || {};

if(valObject.arrayOk && (Array.isArray(newVal) || Array.isArray(oldVal))) {
flags.docalc = true;
Copy link
Copy Markdown
Contributor Author

@etpinard etpinard Mar 16, 2017

Choose a reason for hiding this comment

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

Previously, calls like restyle(gd, 'marker.size', [[10, 30, 20]]) worked only when one or several axis autorange were turned on as this too clears gd.calcdata.

This here now ensures that restyling any arrayOk key clears gd.calcdata.

Copy link
Copy Markdown
Contributor Author

@etpinard etpinard Mar 16, 2017

Choose a reason for hiding this comment

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

@alexcjohnson using _module.attributes here to find the arrayOk keys worked surprisingly well. We could declare a few more keys in the attributes to resolve #648 at some point.


mockDefaultsAndCalc(gd);
Plotly.restyle(gd, 'marker.color', [['red', 'green', 'blue']]);
expect(gd.calcdata).toBeUndefined();
Copy link
Copy Markdown
Contributor Author

@etpinard etpinard Mar 16, 2017

Choose a reason for hiding this comment

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

this means restyle clears gd.calcdata.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that Plotly.plot is mocked in this suite.

@alexcjohnson
Copy link
Copy Markdown
Collaborator

Nice job tracking this down - fix & tests look spot on! 💃

@etpinard etpinard merged commit d9f6c1b into master Mar 16, 2017
@etpinard etpinard deleted the restyle-docalc branch March 16, 2017 20:33
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.

Marker styles are not updated with Plotly.restyle in zoomed state until double-click to zoom out

2 participants