Skip to content

Commit a0f8333

Browse files
authored
Merge pull request #1737 from plotly/fix-transform-animate
clear calcdata before redoing it in animations
2 parents 5ac8c39 + fdf27cb commit a0f8333

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/plots/plots.js

+4
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,10 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
18131813
// of essentially the whole supplyDefaults step, so that it seems sensible to just use
18141814
// supplyDefaults even though it's heavier than would otherwise be desired for
18151815
// transitions:
1816+
1817+
// first delete calcdata so supplyDefaults knows a calc step is coming
1818+
delete gd.calcdata;
1819+
18161820
plots.supplyDefaults(gd);
18171821

18181822
plots.doCalcdata(gd);

test/jasmine/tests/animate_test.js

+22
Original file line numberDiff line numberDiff line change
@@ -768,4 +768,26 @@ describe('animating scatter traces', function() {
768768
expect(trace.style('opacity')).toEqual('0.1');
769769
}).catch(fail).then(done);
770770
});
771+
772+
it('computes calcdata correctly when transforms are present', function(done) {
773+
Plotly.plot(gd, {
774+
data: [{
775+
x: [1, 2, 3],
776+
y: [1, 2, 3],
777+
mode: 'markers',
778+
transforms: [{
779+
type: 'sort',
780+
target: [1, 3, 2]
781+
}]
782+
}],
783+
frames: [
784+
{name: 'frame1', data: [{y: [1, 2, 3]}]},
785+
{name: 'frame2', data: [{y: [3, 1, 2]}]}
786+
]
787+
}).then(function() {
788+
return Plotly.animate(gd, ['frame2'], {frame: {duration: 200, redraw: false}});
789+
}).then(function() {
790+
expect(gd.calcdata[0][0].y).toEqual(3);
791+
}).catch(fail).then(done);
792+
});
771793
});

0 commit comments

Comments
 (0)