Skip to content
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

clear calcdata before redoing it in animations #1737

Merged
merged 4 commits into from
May 26, 2017
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
4 changes: 4 additions & 0 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,10 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
// of essentially the whole supplyDefaults step, so that it seems sensible to just use
// supplyDefaults even though it's heavier than would otherwise be desired for
// transitions:

// first delete calcdata so supplyDefaults knows a calc step is coming
delete gd.calcdata;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a solid fix. It will slow down Plotly.animate though.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's some logic in Plots.doCalcdata involving old versus new calcdata that might be obsolete now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will it? We're calling doCalcdata no matter what so I'd think this will actually speed it up a tiny bit!

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point 👍


plots.supplyDefaults(gd);

plots.doCalcdata(gd);
Expand Down
22 changes: 22 additions & 0 deletions test/jasmine/tests/animate_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,4 +768,26 @@ describe('animating scatter traces', function() {
expect(trace.style('opacity')).toEqual('0.1');
}).catch(fail).then(done);
});

it('computes calcdata correctly when transforms are present', function(done) {
Plotly.plot(gd, {
data: [{
x: [1, 2, 3],
y: [1, 2, 3],
mode: 'markers',
transforms: [{
type: 'sort',
target: [1, 3, 2]
}]
}],
frames: [
{name: 'frame1', data: [{y: [1, 2, 3]}]},
{name: 'frame2', data: [{y: [3, 1, 2]}]}
]
}).then(function() {
return Plotly.animate(gd, ['frame2'], {frame: {duration: 200, redraw: false}});
}).then(function() {
expect(gd.calcdata[0][0].y).toEqual(3);
}).catch(fail).then(done);
});
});