Skip to content

Commit 57c7779

Browse files
committed
Call cleanPlot from newPlot directly; Changed the location of the trace dispose loop; null -> delete
1 parent 6c92920 commit 57c7779

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

src/plot_api/plot_api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,10 @@ Plotly.redraw = function(gd) {
835835
*/
836836
Plotly.newPlot = function(gd, data, layout, config) {
837837
gd = getGraphDiv(gd);
838+
839+
// remove gl contexts
840+
Plots.cleanPlot([], {}, gd._fullData || {}, gd._fullLayout || {});
841+
838842
Plots.purge(gd);
839843
return Plotly.plot(gd, data, layout, config);
840844
};

src/plots/gl2d/scene2d.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ proto.cameraChanged = function() {
310310
};
311311

312312
proto.destroy = function() {
313+
314+
var traces = this.traces;
315+
316+
if(traces) {
317+
Object.keys(traces).map(function(key) {
318+
traces[key].dispose();
319+
delete traces[key];
320+
});
321+
}
322+
313323
this.glplot.dispose();
314324

315325
if(!this.staticPlot) this.container.removeChild(this.canvas);
@@ -318,14 +328,6 @@ proto.destroy = function() {
318328

319329
this.glplot = null;
320330
this.stopped = true;
321-
322-
var traces = this.traces;
323-
if(traces) {
324-
Object.keys(traces).map(function(key) {
325-
traces[key].dispose();
326-
traces[key] = null;
327-
});
328-
}
329331
};
330332

331333
proto.plot = function(fullData, calcData, fullLayout) {

src/plots/plots.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -809,16 +809,6 @@ plots.purge = function(gd) {
809809
// remove modebar
810810
if(fullLayout._modeBar) fullLayout._modeBar.destroy();
811811

812-
if(fullLayout._plots) {
813-
Object.keys(fullLayout._plots).map(function(key) {
814-
var plot = fullLayout._plots[key];
815-
if(plot._scene2d) {
816-
plot._scene2d.destroy();
817-
plot._scene2d = null;
818-
}
819-
});
820-
}
821-
822812
// data and layout
823813
delete gd.data;
824814
delete gd.layout;

0 commit comments

Comments
 (0)