Skip to content

Commit f6c5d56

Browse files
committed
fix #3002 - allow deleting stack groups
and along the way speed up trace deletion in general, by not redrawing all the points in the deleted trace immediately before removing them!
1 parent 37ee992 commit f6c5d56

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/traces/scatter/plot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition
7272
});
7373
});
7474
} else {
75-
scatterLayer.selectAll('g.trace').each(function(d, i) {
75+
join.each(function(d, i) {
7676
plotOne(gd, i, plotinfo, d, cdscatterSorted, this, transitionOpts);
7777
});
7878
}

test/jasmine/tests/scatter_test.js

+33
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,39 @@ describe('stacked area', function() {
11841184
.then(done);
11851185
});
11861186

1187+
it('can add/delete stack groups', function(done) {
1188+
var data01 = [
1189+
{mode: 'markers', y: [1, 2, -1, 2, 1], stackgroup: 'a'},
1190+
{mode: 'markers', y: [2, 3, 2, 3, 2], stackgroup: 'b'}
1191+
];
1192+
var data0 = [Lib.extendDeep({}, data01[0])];
1193+
var data1 = [Lib.extendDeep({}, data01[1])];
1194+
1195+
function _assert(yRange, nTraces) {
1196+
expect(gd._fullLayout.yaxis.range).toBeCloseToArray(yRange, 2);
1197+
expect(gd.querySelectorAll('g.trace.scatter').length).toBe(nTraces);
1198+
}
1199+
1200+
Plotly.newPlot(gd, data01)
1201+
.then(function() {
1202+
_assert([-1.293, 3.293], 2);
1203+
return Plotly.react(gd, data0);
1204+
})
1205+
.then(function() {
1206+
_assert([-1.220, 2.220], 1);
1207+
return Plotly.react(gd, data01);
1208+
})
1209+
.then(function() {
1210+
_assert([-1.293, 3.293], 2);
1211+
return Plotly.react(gd, data1);
1212+
})
1213+
.then(function() {
1214+
_assert([0, 3.205], 1);
1215+
})
1216+
.catch(failTest)
1217+
.then(done);
1218+
});
1219+
11871220
it('does not stack on date axes', function(done) {
11881221
Plotly.newPlot(gd, [
11891222
{y: ['2016-01-01', '2017-01-01'], stackgroup: 'a'},

0 commit comments

Comments
 (0)