X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=da2a11a5d7594b210738deedbac280b115b7aa2c;hb=86a3e64f8f73d854b3b4ac35f52b54bfda3056a4;hp=79b53a939248263160b32a81f92c6e7f8c4a94d7;hpb=9d31b3fe6bb776384da58c37dc9b2ba1304f1fd0;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 79b53a9..da2a11a 100644 --- a/dygraph.js +++ b/dygraph.js @@ -61,17 +61,15 @@ * whether the input data contains error ranges. For a complete list of * options, see http://dygraphs.com/options.html. */ -var Dygraph = function(div, data, opts) { - if (arguments.length > 0) { - if (arguments.length == 4) { - // Old versions of dygraphs took in the series labels as a constructor - // parameter. This doesn't make sense anymore, but it's easy to continue - // to support this usage. - this.warn("Using deprecated four-argument dygraph constructor"); - this.__old_init__(div, data, arguments[2], arguments[3]); - } else { - this.__init__(div, data, opts); - } +var Dygraph = function(div, data, opts, opt_fourth_param) { + if (opt_fourth_param !== undefined) { + // Old versions of dygraphs took in the series labels as a constructor + // parameter. This doesn't make sense anymore, but it's easy to continue + // to support this usage. + this.warn("Using deprecated four-argument dygraph constructor"); + this.__old_init__(div, data, opts, opt_fourth_param); + } else { + this.__init__(div, data, opts); } }; @@ -851,12 +849,12 @@ Dygraph.prototype.createInterface_ = function() { var dygraph = this; this.mouseMoveHandler = function(e) { - dygraph.mouseMove_(e); + dygraph.mouseMove_(e); }; Dygraph.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler); this.mouseOutHandler = function(e) { - dygraph.mouseOut_(e); + dygraph.mouseOut_(e); }; Dygraph.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler); @@ -888,6 +886,7 @@ Dygraph.prototype.destroy = function() { // remove mouse event handlers 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) { @@ -1014,6 +1013,7 @@ Dygraph.prototype.createStatusMessage_ = function() { "top": "0px", "left": (this.width_ - divWidth - 2) + "px", "background": "white", + "lineHeight": "normal", "textAlign": "left", "overflow": "hidden"}; Dygraph.update(messagestyle, this.attr_('labelsDivStyles')); @@ -1120,6 +1120,7 @@ Dygraph.prototype.createDragInterface_ = function() { prevEndX: null, // pixel coordinates prevEndY: null, // pixel coordinates prevDragDirection: null, + cancelNextDblclick: false, // see comment in dygraph-interaction-model.js // The value on the left side of the graph when a pan operation starts. initialLeftmostDate: null, @@ -1156,6 +1157,7 @@ Dygraph.prototype.createDragInterface_ = function() { context.py = Dygraph.findPosY(g.canvas_); context.dragStartX = g.dragGetX_(event, context); context.dragStartY = g.dragGetY_(event, context); + context.cancelNextDblclick = false; } }; @@ -1179,7 +1181,7 @@ Dygraph.prototype.createDragInterface_ = function() { // If the user releases the mouse button during a drag, but not over the // canvas, then it doesn't count as a zooming action. - Dygraph.addEvent(document, 'mouseup', function(event) { + this.mouseUpHandler_ = function(event) { if (context.isZooming || context.isPanning) { context.isZooming = false; context.dragStartX = null; @@ -1195,7 +1197,9 @@ Dygraph.prototype.createDragInterface_ = function() { delete self.axes_[i].dragValueRange; } } - }); + }; + + Dygraph.addEvent(document, 'mouseup', this.mouseUpHandler_); }; /** @@ -1842,6 +1846,8 @@ Dygraph.prototype.generateLegendHTML_ = function(x, sel_points, oneEmWidth) { */ Dygraph.prototype.setLegendHTML_ = function(x, sel_points) { var labelsDiv = this.attr_("labelsDiv"); + if (!labelsDiv) return; + var sizeSpan = document.createElement('span'); // Calculates the width of 1em in pixels for the legend. sizeSpan.setAttribute('style', 'margin: 0; padding: 0 0 0 1em; border: 0;');