From c91f4ae8a74ce76f5207f0c2875bc596da8a61fa Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Mon, 1 Nov 2010 10:58:25 -0700 Subject: [PATCH] fix memory leak when gviz.draw() is called repeatedly --- dygraph.js | 7 +++++++ 1 file changed, 7 insertions(+) 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); } -- 2.7.4