Skip to content

Commit 610ac45

Browse files
committed
fix #2602 - Plotly.react add/remove traces bug
1 parent c91866d commit 610ac45

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/plot_api/plot_api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,7 @@ function diffData(gd, oldFullData, newFullData, immutable) {
23722372
if(oldFullData.length !== newFullData.length) {
23732373
return {
23742374
fullReplot: true,
2375-
clearCalc: true
2375+
calc: true
23762376
};
23772377
}
23782378

test/jasmine/tests/plot_api_test.js

+23
Original file line numberDiff line numberDiff line change
@@ -2610,6 +2610,29 @@ describe('Test plot api', function() {
26102610
images.draw.calls.reset();
26112611
}
26122612

2613+
it('can add / remove traces', function(done) {
2614+
var data1 = [{y: [1, 2, 3], mode: 'markers'}];
2615+
var data2 = [data1[0], {y: [2, 3, 1], mode: 'markers'}];
2616+
var layout = {};
2617+
Plotly.newPlot(gd, data1, layout)
2618+
.then(countPlots)
2619+
.then(function() {
2620+
expect(d3.selectAll('.point').size()).toBe(3);
2621+
2622+
return Plotly.react(gd, data2, layout);
2623+
})
2624+
.then(function() {
2625+
expect(d3.selectAll('.point').size()).toBe(6);
2626+
2627+
return Plotly.react(gd, data1, layout);
2628+
})
2629+
.then(function() {
2630+
expect(d3.selectAll('.point').size()).toBe(3);
2631+
})
2632+
.catch(failTest)
2633+
.then(done);
2634+
});
2635+
26132636
it('should notice new data by ===, without layout.datarevision', function(done) {
26142637
var data = [{y: [1, 2, 3], mode: 'markers'}];
26152638
var layout = {};

0 commit comments

Comments
 (0)