var dygraph = this;
- this.mouseMoveHandler = function(e) {
+ this.mouseMoveHandler_ = function(e) {
dygraph.mouseMove_(e);
};
- this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
- this.mouseOutHandler = function(e) {
+ this.mouseOutHandler_ = function(e) {
dygraph.mouseOut_(e);
};
- this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
- this.resizeHandler = function(e) {
- dygraph.resize();
- };
+ this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_);
+ this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_);
+
+ // Don't recreate and register the resize handler on subsequent calls.
+ // This happens when the graph is resized.
+ if (!this.resizeHandler_) {
+ this.resizeHandler_ = function(e) {
+ dygraph.resize();
+ };
- // Update when the window is resized.
- // TODO(danvk): drop frames depending on complexity of the chart.
- this.addEvent(window, 'resize', this.resizeHandler);
+ // Update when the window is resized.
+ // TODO(danvk): drop frames depending on complexity of the chart.
+ this.addEvent(window, 'resize', this.resizeHandler_);
+ }
};
/**
this.registeredEvents_ = [];
// remove mouse event handlers (This may not be necessary anymore)
- Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
- Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
+ Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_);
+ Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_);
Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseUpHandler_);
+
+ // remove window handlers
+ Dygraph.removeEvent(window,'resize',this.resizeHandler_);
+ this.resizeHandler_ = null;
+
removeRecursive(this.maindiv_);
var nullOut = function(obj) {
}
}
};
- // remove event handlers
- Dygraph.removeEvent(window,'resize',this.resizeHandler);
- this.resizeHandler = null;
// These may not all be necessary, but it can't hurt...
nullOut(this.layout_);
nullOut(this.plotter_);
bindHandler(interactionModel[eventName]));
}
+ // unregister the handler on subsequent calls.
+ // This happens when the graph is resized.
+ if (this.mouseUpHandler_) {
+ Dygraph.removeEvent(document, 'mouseup', this.mouseUpHandler_);
+ }
+
// If the user releases the mouse button during a drag, but not over the
// canvas, then it doesn't count as a zooming action.
this.mouseUpHandler_ = function(event) {
if (this.attr_("timingName")) {
var end = new Date();
- if (console) {
- console.log(this.attr_("timingName") + " - drawGraph: " + (end - start) + "ms");
- }
+ Dygraph.info(this.attr_("timingName") + " - drawGraph: " + (end - start) + "ms");
}
};
* This fills in the valueRange and ticks fields in each entry of this.axes_.
*/
Dygraph.prototype.computeYAxisRanges_ = function(extremes) {
+
+ var isNullUndefinedOrNaN = function(num) {
+ return isNaN(parseFloat(num));
+ };
var series;
var numAxes = this.attributes_.numAxes();
} else if (axis.valueRange) {
// This is a user-set value range for this axis.
axis.computedValueRange = [
- !isNaN(axis.valueRange[0]) && axis.valueRange[0] !== null && axis.valueRange[0] !== undefined ? axis.valueRange[0] : axis.extremeRange[0],
- !isNaN(axis.valueRange[1]) && axis.valueRange[1] !== null && axis.valueRange[1] !== undefined ? axis.valueRange[1] : axis.extremeRange[1]
+ isNullUndefinedOrNaN(axis.valueRange[0]) ? axis.extremeRange[0] : axis.valueRange[0],
+ isNullUndefinedOrNaN(axis.valueRange[1]) ? axis.extremeRange[1] : axis.valueRange[1]
];
} else {
axis.computedValueRange = axis.extremeRange;