From: Robert Konigsberg Date: Wed, 23 Apr 2014 12:47:08 +0000 (-0400) Subject: Merge branch 'master' into xlog X-Git-Tag: v1.1.0~60^2~1^2~2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=335011fd4473f55aaaceb69726d15e0063373149;p=dygraphs.git Merge branch 'master' into xlog Conflicts: dygraph-layout.js --- 335011fd4473f55aaaceb69726d15e0063373149 diff --cc dygraph-interaction-model.js index 56491e1,75ee78f..c97b060 --- a/dygraph-interaction-model.js +++ b/dygraph-interaction-model.js @@@ -38,18 -38,12 +38,18 @@@ Dygraph.Interaction.startPan = function var i, axis; context.isPanning = true; var xRange = g.xAxisRange(); - context.dateRange = xRange[1] - xRange[0]; - context.initialLeftmostDate = xRange[0]; + + if (g.getOptionForAxis("logscale", 'x')) { + context.initialLeftmostDate = Dygraph.log10(xRange[0]); + context.dateRange = Dygraph.log10(xRange[1]) - Dygraph.log10(xRange[0]); + } else { + context.initialLeftmostDate = xRange[0]; + context.dateRange = xRange[1] - xRange[0]; + } context.xUnitsPerPixel = context.dateRange / (g.plotter_.area.w - 1); - if (g.attr_("panEdgeFraction")) { - var maxXPixelsToDraw = g.width_ * g.attr_("panEdgeFraction"); + if (g.getNumericOption("panEdgeFraction")) { + var maxXPixelsToDraw = g.width_ * g.getNumericOption("panEdgeFraction"); var xExtremes = g.xAxisExtremes(); // I REALLY WANT TO CALL THIS xTremes! var boundedLeftX = g.toDomXCoord(xExtremes[0]) - maxXPixelsToDraw; diff --cc dygraph-layout.js index 2e81359,4caa935..20e8481 --- a/dygraph-layout.js +++ b/dygraph-layout.js @@@ -212,17 -207,16 +212,24 @@@ DygraphLayout.prototype._evaluateLimit } }; - DygraphLayout._calcXNormal = function(value, axis, logscale) { ++DygraphLayout.calcXNormal_ = function(value, axis, logscale) { + if (logscale) { + return ((Dygraph.log10(value) - Dygraph.log10(axis.minxval)) * axis.xlogscale); + } else { + return (value - axis.minxval) * axis.xscale; + } +}; + - DygraphLayout._calcYNormal = function(axis, value, logscale) { + /** + * @param {DygraphAxisType} axis + * @param {number} value + * @param {boolean} logscale + * @return {number} + */ + DygraphLayout.calcYNormal_ = function(axis, value, logscale) { if (logscale) { - return 1.0 - ((Dygraph.log10(value) - Dygraph.log10(axis.minyval)) * axis.ylogscale); + var x = 1.0 - ((Dygraph.log10(value) - Dygraph.log10(axis.minyval)) * axis.ylogscale); + return isFinite(x) ? x : NaN; // shim for v8 issue; see pull request 276 } else { return 1.0 - ((value - axis.minyval) * axis.yscale); } @@@ -244,7 -237,7 +251,7 @@@ DygraphLayout.prototype._evaluateLineCh var point = points[j]; // Range from 0-1 where 0 represents left and 1 represents right. - point.x = DygraphLayout._calcXNormal(point.xval, this._xAxis, isLogscaleForX); - point.x = (point.xval - this.minxval) * this.xscale; ++ point.x = DygraphLayout.calcXNormal_(point.xval, this._xAxis, isLogscaleForX); // Range from 0-1 where 0 represents top and 1 represents bottom var yval = point.yval; if (isStacked) { @@@ -287,8 -266,8 +280,8 @@@ DygraphLayout.prototype._evaluateLineTi for (i = 0; i < this.xTicks_.length; i++) { tick = this.xTicks_[i]; label = tick.label; - pos = this.xscale * (tick.v - this.minxval); + pos = this.dygraph_.toPercentXCoord(tick.v); - if ((pos >= 0.0) && (pos <= 1.0)) { + if ((pos >= 0.0) && (pos < 1.0)) { this.xticks.push([pos, label]); } } diff --cc dygraph.js index 6c76b78,56eea79..9570d3c --- a/dygraph.js +++ b/dygraph.js @@@ -3218,11 -3183,11 +3238,11 @@@ Dygraph.prototype.parseDataTable_ = fun } else if (indepType == 'number') { this.attrs_.xValueParser = function(x) { return parseFloat(x); }; this.attrs_.axes.x.valueFormatter = function(x) { return x; }; - this.attrs_.axes.x.ticker = Dygraph.numericLinearTicks; + this.attrs_.axes.x.ticker = Dygraph.numericTicks; this.attrs_.axes.x.axisLabelFormatter = this.attrs_.axes.x.valueFormatter; } else { - this.error("only 'date', 'datetime' and 'number' types are supported for " + - "column 1 of DataTable input (Got '" + indepType + "')"); + Dygraph.error("only 'date', 'datetime' and 'number' types are supported " + + "for column 1 of DataTable input (Got '" + indepType + "')"); return null; }