X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=abd297396150d67d14251e74517376ddebc3757e;hb=e79c8bec6d181f70521450a22b5174a41495ec9b;hp=3867b290d06939922947f6c15d5937b719bd8b48;hpb=6a4457b403f78ba559550f97330ac25ee4d9629f;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 3867b29..abd2973 100644 --- a/dygraph.js +++ b/dygraph.js @@ -233,6 +233,7 @@ Dygraph.DEFAULT_ATTRS = { stepPlot: false, avoidMinZero: false, + drawAxesAtZero: false, // Sizes of the various chart labels. titleHeight: 28, @@ -407,6 +408,8 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { this.setIndexByName_ = {}; this.datasetIndex_ = []; + this.registeredEvents_ = []; + // Create the containing DIV and other interactive elements this.createInterface_(); @@ -424,6 +427,7 @@ Dygraph.prototype.__init__ = function(div, file, attrs) { var handlers = pluginInstance.activate(this); for (var eventName in handlers) { + // TODO(danvk): validate eventName. pluginDict.events[eventName] = handlers[eventName]; } @@ -949,12 +953,12 @@ Dygraph.prototype.createInterface_ = function() { this.mouseMoveHandler = function(e) { dygraph.mouseMove_(e); }; - Dygraph.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler); + this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler); this.mouseOutHandler = function(e) { dygraph.mouseOut_(e); }; - Dygraph.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler); + this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler); this.createDragInterface_(); @@ -964,7 +968,7 @@ Dygraph.prototype.createInterface_ = function() { // Update when the window is resized. // TODO(danvk): drop frames depending on complexity of the chart. - Dygraph.addEvent(window, 'resize', this.resizeHandler); + this.addEvent(window, 'resize', this.resizeHandler); }; /** @@ -979,8 +983,14 @@ Dygraph.prototype.destroy = function() { node.removeChild(node.firstChild); } }; - - // remove mouse event handlers + + for (var idx = 0; idx < this.registeredEvents_.length; idx++) { + var reg = this.registeredEvents_[idx]; + Dygraph.removeEvent(reg.elem, reg.type, reg.fn); + } + 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_, 'mousemove', this.mouseUpHandler_); @@ -1213,7 +1223,8 @@ Dygraph.prototype.createDragInterface_ = function() { boundedDates: null, // [minDate, maxDate] boundedValues: null, // [[minValue, maxValue] ...] - initializeMouseDown: function(event, g, context) { + // contextB is the same thing as this context object but renamed. + initializeMouseDown: function(event, g, contextB) { // prevents mouse drags from selecting page text. if (event.preventDefault) { event.preventDefault(); // Firefox, Chrome, etc. @@ -1222,11 +1233,11 @@ Dygraph.prototype.createDragInterface_ = function() { event.cancelBubble = true; } - context.px = Dygraph.findPosX(g.canvas_); - context.py = Dygraph.findPosY(g.canvas_); - context.dragStartX = g.dragGetX_(event, context); - context.dragStartY = g.dragGetY_(event, context); - context.cancelNextDblclick = false; + contextB.px = Dygraph.findPosX(g.canvas_); + contextB.py = Dygraph.findPosY(g.canvas_); + contextB.dragStartX = g.dragGetX_(event, contextB); + contextB.dragStartY = g.dragGetY_(event, contextB); + contextB.cancelNextDblclick = false; } }; @@ -1244,7 +1255,7 @@ Dygraph.prototype.createDragInterface_ = function() { for (var eventName in interactionModel) { if (!interactionModel.hasOwnProperty(eventName)) continue; - Dygraph.addEvent(this.mouseEventElement_, eventName, + this.addEvent(this.mouseEventElement_, eventName, bindHandler(interactionModel[eventName])); } @@ -1268,7 +1279,7 @@ Dygraph.prototype.createDragInterface_ = function() { } }; - Dygraph.addEvent(document, 'mouseup', this.mouseUpHandler_); + this.addEvent(document, 'mouseup', this.mouseUpHandler_); }; /**