reasonable behavior for title
[dygraphs.git] / dygraph.js
index 6c15698..38c1d05 100644 (file)
@@ -233,6 +233,7 @@ Dygraph.DEFAULT_ATTRS = {
 
   stepPlot: false,
   avoidMinZero: false,
+  drawAxesAtZero: false,
 
   // Sizes of the various chart labels.
   titleHeight: 28,
@@ -985,14 +986,14 @@ Dygraph.prototype.destroy = function() {
  
   for (var idx = 0; idx < this.registeredEvents_.length; idx++) {
     var reg = this.registeredEvents_[idx];
-    this.removeEvent(reg.elem, reg.type, reg.fn);
+    Dygraph.removeEvent(reg.elem, reg.type, reg.fn);
   }
   this.registeredEvents_ = [];
 
   // remove mouse event handlers (This may not be necessary anymore)
-  this.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
-  this.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
-  this.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseUpHandler_);
+  Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
+  Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
+  Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseUpHandler_);
   removeRecursive(this.maindiv_);
 
   var nullOut = function(obj) {
@@ -1003,7 +1004,7 @@ Dygraph.prototype.destroy = function() {
     }
   };
   // remove event handlers
-  this.removeEvent(window,'resize',this.resizeHandler);
+  Dygraph.removeEvent(window,'resize',this.resizeHandler);
   this.resizeHandler = null;
   // These may not all be necessary, but it can't hurt...
   nullOut(this.layout_);
@@ -2101,7 +2102,10 @@ Dygraph.prototype.predraw_ = function() {
   this.computeYAxes_();
 
   // Create a new plotter.
-  if (this.plotter_) this.plotter_.clear();
+  if (this.plotter_) {
+    this.cascadeEvents_('clearChart');
+    this.plotter_.clear();
+  }
   this.plotter_ = new DygraphCanvasRenderer(this,
                                             this.hidden_,
                                             this.hidden_ctx_,
@@ -2329,8 +2333,13 @@ Dygraph.prototype.drawGraph_ = function() {
  * @private
  */
 Dygraph.prototype.renderGraph_ = function(is_initial_draw) {
+  this.cascadeEvents_('clearChart');
   this.plotter_.clear();
+
   this.plotter_.render();
+
+  // TODO(danvk): is this a performance bottleneck when panning?
+  // The interaction canvas should already be empty in that situation.
   this.canvas_.getContext('2d').clearRect(0, 0, this.canvas_.width,
                                           this.canvas_.height);