fix clearChart double-firing merge-hairline
authorDan Vanderkam <danvdk@gmail.com>
Sun, 16 Nov 2014 23:47:31 +0000 (18:47 -0500)
committerDan Vanderkam <danvdk@gmail.com>
Sun, 16 Nov 2014 23:47:31 +0000 (18:47 -0500)
auto_tests/tests/plugins.js
dygraph.js

index cff1d92..5655585 100644 (file)
@@ -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);
index c8a1ccf..026365b 100644 (file)
@@ -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_,