Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 36 additions & 0 deletions src/plots/cartesian/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,39 @@ exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
}
}
};

exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
var oldModules = oldFullLayout._modules || [],
newModules = newFullLayout._modules || [];

var hadScatter, hasScatter, i;

for(i = 0; i < oldModules.length; i++) {
if(oldModules[i].name === 'scatter') {
hadScatter = true;
break;
}
}

for(i = 0; i < newModules.length; i++) {
if(newModules[i].name === 'scatter') {
hasScatter = true;
break;
}
}

if(hadScatter && !hasScatter) {
var oldPlots = oldFullLayout._plots,
ids = Object.keys(oldPlots || {});

for(i = 0; i < ids.length; i++) {
var subplotInfo = oldPlots[ids[i]];

if(subplotInfo.plot) {
subplotInfo.plot.select('g.scatterlayer')
.selectAll('g.trace')
.remove();
}
}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

3 changes: 1 addition & 2 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ plots.supplyTraceDefaults = function(traceIn, traceIndex, layout) {

coerce('type');
coerce('uid');
coerce('name', 'trace ' + traceIndex);

// coerce subplot attributes of all registered subplot types
var subplotTypes = Object.keys(subplotsRegistry);
Expand All @@ -733,8 +734,6 @@ plots.supplyTraceDefaults = function(traceIn, traceIndex, layout) {

if(_module) _module.supplyDefaults(traceIn, traceOut, defaultColor, layout);

coerce('name', 'trace ' + traceIndex);

if(!plots.traceIs(traceOut, 'noOpacity')) coerce('opacity');

coerceSubplotAttr('cartesian', 'xaxis');
Expand Down
5 changes: 5 additions & 0 deletions test/jasmine/tests/cartesian_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ describe('restyle', function() {

// The second has been recreated so is different:
expect(firstToNext).not.toBe(secondToNext);

return Plotly.restyle(gd, 'visible', false);
}).then(function() {
expect(d3.selectAll('g.trace.scatter').size()).toEqual(0);

}).then(done);
});

Expand Down