Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 610ac45

Browse filesBrowse files
committed
fix plotly#2602 - Plotly.react add/remove traces bug
1 parent c91866d commit 610ac45
Copy full SHA for 610ac45

File tree

Expand file treeCollapse file tree

2 files changed

+24
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+24
-1
lines changed

‎src/plot_api/plot_api.js

Copy file name to clipboardExpand all lines: src/plot_api/plot_api.js
+1-1Lines changed: 1 addition & 1 deletion
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

Copy file name to clipboardExpand all lines: test/jasmine/tests/plot_api_test.js
+23Lines changed: 23 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.