From: Dan Vanderkam Date: Mon, 1 Nov 2010 17:58:25 +0000 (-0700) Subject: fix memory leak when gviz.draw() is called repeatedly X-Git-Tag: v1.0.0~616 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=c91f4ae8a74ce76f5207f0c2875bc596da8a61fa;p=dygraphs.git fix memory leak when gviz.draw() is called repeatedly --- diff --git a/dygraph.js b/dygraph.js index b909aa7..51e656c 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2922,7 +2922,14 @@ Dygraph.GVizChart = function(container) { } Dygraph.GVizChart.prototype.draw = function(data, options) { + // Clear out any existing dygraph. + // TODO(danvk): would it make more sense to simply redraw using the current + // date_graph object? this.container.innerHTML = ''; + if (typeof(this.date_graph) != 'undefined') { + this.date_graph.destroy(); + } + this.date_graph = new Dygraph(this.container, data, options); }