From c04c8044c2f04d8db1d7987cc5cb181c03f9d7df Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 16 Nov 2014 18:47:31 -0500 Subject: [PATCH] fix clearChart double-firing --- auto_tests/tests/plugins.js | 6 ++---- dygraph.js | 7 +------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/auto_tests/tests/plugins.js b/auto_tests/tests/plugins.js index cff1d92..5655585 100644 --- a/auto_tests/tests/plugins.js +++ b/auto_tests/tests/plugins.js @@ -183,9 +183,8 @@ pluginsTestCase.prototype.testEventSequence = function() { events = []; g.updateOptions({series: {Y1: {color: 'blue'}}}); assertEquals([ - "clearChart", "predraw", - "clearChart", // why is clearChart called twice? + "clearChart", "willDrawChart", "didDrawChart" ], events); @@ -207,9 +206,8 @@ pluginsTestCase.prototype.testEventSequence = function() { assertEquals([ "dataWillUpdate", "dataDidUpdate", - "clearChart", "predraw", - "clearChart", // why is clearChart called twice? + "clearChart", "willDrawChart", "didDrawChart" ], events); diff --git a/dygraph.js b/dygraph.js index c8a1ccf..026365b 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2358,12 +2358,6 @@ Dygraph.prototype.predraw_ = function() { // TODO(danvk): move more computations out of drawGraph_ and into here. this.computeYAxes_(); - // Create a new plotter. - if (this.plotter_) { - this.cascadeEvents_('clearChart'); - this.plotter_.clear(); - } - if (!this.is_initial_draw_) { this.canvas_ctx_.restore(); this.hidden_ctx_.restore(); @@ -2372,6 +2366,7 @@ Dygraph.prototype.predraw_ = function() { this.canvas_ctx_.save(); this.hidden_ctx_.save(); + // Create a new plotter. this.plotter_ = new DygraphCanvasRenderer(this, this.hidden_, this.hidden_ctx_, -- 2.7.4