X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=dygraph.js;h=a95b91d36e744150533d204e9a3181419ee5acc7;hb=d3b990da77ec190c27faf0fb5c7a6a4034880c2f;hp=456a56c8f44e2c595e3ffaacb0937bba044ef8f7;hpb=fc1c2420cb32dd154c8d88e51780f8a3788a94fe;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 456a56c..a95b91d 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1301,24 +1301,6 @@ Dygraph.prototype.createRollInterface_ = function() { }; /** - * @private - * Converts page the x-coordinate of the event to pixel x-coordinates on the - * canvas (i.e. DOM Coords). - */ -Dygraph.prototype.dragGetX_ = function(e, context) { - return Dygraph.pageX(e) - context.px; -}; - -/** - * @private - * Converts page the y-coordinate of the event to pixel y-coordinates on the - * canvas (i.e. DOM Coords). - */ -Dygraph.prototype.dragGetY_ = function(e, context) { - return Dygraph.pageY(e) - context.py; -}; - -/** * Set up all the mouse handlers needed to capture dragging behavior for zoom * events. * @private @@ -1378,8 +1360,8 @@ Dygraph.prototype.createDragInterface_ = function() { var canvasPos = Dygraph.findPos(g.canvas_); contextB.px = canvasPos.x; contextB.py = canvasPos.y; - contextB.dragStartX = g.dragGetX_(event, contextB); - contextB.dragStartY = g.dragGetY_(event, contextB); + contextB.dragStartX = Dygraph.dragGetX_(event, contextB); + contextB.dragStartY = Dygraph.dragGetY_(event, contextB); contextB.cancelNextDblclick = false; contextB.tarp.cover(); } @@ -1735,7 +1717,7 @@ Dygraph.prototype.eventToDomCoords = function(event) { if (event.offsetX && event.offsetY) { return [ event.offsetX, event.offsetY ]; } else { - var eventElementPos = Dygraph.findPos(this.mouseEventElement_) + var eventElementPos = Dygraph.findPos(this.mouseEventElement_); var canvasx = Dygraph.pageX(event) - eventElementPos.x; var canvasy = Dygraph.pageY(event) - eventElementPos.y; return [canvasx, canvasy]; @@ -2921,40 +2903,6 @@ Dygraph.prototype.setXAxisOptions_ = function(isDate) { }; /** - * Parses the value as a floating point number. This is like the parseFloat() - * built-in, but with a few differences: - * - the empty string is parsed as null, rather than NaN. - * - if the string cannot be parsed at all, an error is logged. - * If the string can't be parsed, this method returns null. - * @param {String} x The string to be parsed - * @param {Number} opt_line_no The line number from which the string comes. - * @param {String} opt_line The text of the line from which the string comes. - * @private - */ - -// Parse the x as a float or return null if it's not a number. -Dygraph.prototype.parseFloat_ = function(x, opt_line_no, opt_line) { - var val = parseFloat(x); - if (!isNaN(val)) return val; - - // Try to figure out what happeend. - // If the value is the empty string, parse it as null. - if (/^ *$/.test(x)) return null; - - // If it was actually "NaN", return it as NaN. - if (/^ *nan *$/i.test(x)) return NaN; - - // Looks like a parsing error. - var msg = "Unable to parse '" + x + "' as a number"; - if (opt_line !== null && opt_line_no !== null) { - msg += " on line " + (1+opt_line_no) + " ('" + opt_line + "') of CSV."; - } - Dygraph.error(msg); - - return null; -}; - -/** * @private * Parses a string in a special csv format. We expect a csv file where each * line is a date point, and the first field in each line is the date string. @@ -3023,8 +2971,8 @@ Dygraph.prototype.parseCSV_ = function(data) { (1 + i) + " ('" + line + "') which is not of this form."); fields[j] = [0, 0]; } else { - fields[j] = [this.parseFloat_(vals[0], i, line), - this.parseFloat_(vals[1], i, line)]; + fields[j] = [Dygraph.parseFloat_(vals[0], i, line), + Dygraph.parseFloat_(vals[1], i, line)]; } } } else if (this.getBooleanOption("errorBars")) { @@ -3035,8 +2983,8 @@ Dygraph.prototype.parseCSV_ = function(data) { (inFields.length - 1) + "): '" + line + "'"); } for (j = 1; j < inFields.length; j += 2) { - fields[(j + 1) / 2] = [this.parseFloat_(inFields[j], i, line), - this.parseFloat_(inFields[j + 1], i, line)]; + fields[(j + 1) / 2] = [Dygraph.parseFloat_(inFields[j], i, line), + Dygraph.parseFloat_(inFields[j + 1], i, line)]; } } else if (this.getBooleanOption("customBars")) { // Bars are a low;center;high tuple @@ -3047,9 +2995,9 @@ Dygraph.prototype.parseCSV_ = function(data) { } else { vals = val.split(";"); if (vals.length == 3) { - fields[j] = [ this.parseFloat_(vals[0], i, line), - this.parseFloat_(vals[1], i, line), - this.parseFloat_(vals[2], i, line) ]; + fields[j] = [ Dygraph.parseFloat_(vals[0], i, line), + Dygraph.parseFloat_(vals[1], i, line), + Dygraph.parseFloat_(vals[2], i, line) ]; } else { Dygraph.warn('When using customBars, values must be either blank ' + 'or "low;center;high" tuples (got "' + val + @@ -3060,7 +3008,7 @@ Dygraph.prototype.parseCSV_ = function(data) { } else { // Values are just numbers for (j = 1; j < inFields.length; j++) { - fields[j] = this.parseFloat_(inFields[j], i, line); + fields[j] = Dygraph.parseFloat_(inFields[j], i, line); } } if (ret.length > 0 && fields[0] < ret[ret.length - 1][0]) {