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;
}
};
- 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);
}
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) {
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]);
}
}
} 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;
}