Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@ Plotly.redraw = function(gd) {
*/
Plotly.newPlot = function(gd, data, layout, config) {
gd = getGraphDiv(gd);

// remove gl contexts
Plots.cleanPlot([], {}, gd._fullData || {}, gd._fullLayout || {});
Copy link
Contributor

Choose a reason for hiding this comment

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

Great!

@monfera would you adding a test case for checking that Plotly.newPlot does clear existing gl contexts similar to the one for Plots.cleanPlot ?

Thanks in advance.


Plots.purge(gd);
return Plotly.plot(gd, data, layout, config);
};
Expand Down
10 changes: 10 additions & 0 deletions src/plots/gl2d/scene2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,16 @@ proto.cameraChanged = function() {
};

proto.destroy = function() {

var traces = this.traces;

if(traces) {
Object.keys(traces).map(function(key) {
traces[key].dispose();
delete traces[key];
});
}

this.glplot.dispose();

if(!this.staticPlot) this.container.removeChild(this.canvas);
Expand Down