Skip to content

Commit ce58977

Browse files
committed
clean up old scatter traces that were restyle to 'visible: false'
- as of PR #802, scatter traces are no longer purged in the per-subplot cartesian plot step - to maintain consistency between transitions. - While the scatter plot module can remove individual 'visible: false' traces, when all scatter traces are restyled to 'visible: false' the scatter plot module is currently not called!
1 parent 0676a21 commit ce58977

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Diff for: src/plots/cartesian/index.js

+36
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,39 @@ exports.plot = function(gd, traces, transitionOpts, makeOnCompleteCallback) {
110110
}
111111
}
112112
};
113+
114+
exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) {
115+
var oldModules = oldFullLayout._modules,
116+
newModules = newFullLayout._modules;
117+
118+
var hadScatter, hasScatter, i;
119+
120+
for(i = 0; i < oldModules.length; i++) {
121+
if(oldModules[i].name === 'scatter') {
122+
hadScatter = true;
123+
break;
124+
}
125+
}
126+
127+
for(i = 0; i < newModules.length; i++) {
128+
if(newModules[i].name === 'scatter') {
129+
hasScatter = true;
130+
break;
131+
}
132+
}
133+
134+
if(hadScatter && !hasScatter) {
135+
var oldPlots = oldFullLayout._plots,
136+
ids = Object.keys(oldPlots || {});
137+
138+
for(i = 0; i < ids.length; i++) {
139+
var subplotInfo = oldPlots[ids[i]];
140+
141+
if(subplotInfo.plot) {
142+
subplotInfo.plot.select('g.scatterlayer')
143+
.selectAll('g.trace')
144+
.remove();
145+
}
146+
}
147+
}
148+
};

0 commit comments

Comments
 (0)