Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/traces/scatter/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transition
});
});
} else {
scatterLayer.selectAll('g.trace').each(function(d, i) {
join.each(function(d, i) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@etpinard it doesn't seem like animations can remove traces, is that correct? That's what it looks like, since I don't see a join.exit() associated with them (since isFullReplot = !transitionOpts)... yet the comment above implies that you can add traces:

// Must run the selection again since otherwise enters/updates get grouped together
// and these get executed out of order. Except we need them in order!

So... do I need to worry about animations deleting traces or not?

Copy link
Contributor

Choose a reason for hiding this comment

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

do I need to worry about animations deleting traces or not?

Right, removing traces with 'frame.redraw': false (i.e. without a replot at the end of the animation), doesn't work currently:

peek 2018-09-13 16-17

https://codepen.io/etpinard/pen/ZMRReB

so I don't think you broke anything here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah Ricky wrote an issue about this #932

plotOne(gd, i, plotinfo, d, cdscatterSorted, this, transitionOpts);
});
}
Expand Down
33 changes: 33 additions & 0 deletions test/jasmine/tests/scatter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,39 @@ describe('stacked area', function() {
.then(done);
});

it('can add/delete stack groups', function(done) {
var data01 = [
{mode: 'markers', y: [1, 2, -1, 2, 1], stackgroup: 'a'},
{mode: 'markers', y: [2, 3, 2, 3, 2], stackgroup: 'b'}
];
var data0 = [Lib.extendDeep({}, data01[0])];
var data1 = [Lib.extendDeep({}, data01[1])];

function _assert(yRange, nTraces) {
expect(gd._fullLayout.yaxis.range).toBeCloseToArray(yRange, 2);
expect(gd.querySelectorAll('g.trace.scatter').length).toBe(nTraces);
}

Plotly.newPlot(gd, data01)
.then(function() {
_assert([-1.293, 3.293], 2);
return Plotly.react(gd, data0);
})
.then(function() {
_assert([-1.220, 2.220], 1);
return Plotly.react(gd, data01);
})
.then(function() {
_assert([-1.293, 3.293], 2);
return Plotly.react(gd, data1);
})
.then(function() {
_assert([0, 3.205], 1);
})
.catch(failTest)
.then(done);
});

it('does not stack on date axes', function(done) {
Plotly.newPlot(gd, [
{y: ['2016-01-01', '2017-01-01'], stackgroup: 'a'},
Expand Down