Dygraph.DEFAULT_WIDTH = 480;
Dygraph.DEFAULT_HEIGHT = 320;
-Dygraph.ANIMATION_STEPS = 10;
+// For max 60 Hz. animation:
+Dygraph.ANIMATION_STEPS = 12;
Dygraph.ANIMATION_DURATION = 200;
// These are defined before DEFAULT_ATTRS so that it can refer to them.
var yRange = this.yAxisRange(axis);
var pct;
- if (!this.axes_[axis].logscale) {
+ var logscale = this.attributes_.getForAxis("logscale", axis);
+ if (!logscale) {
// yRange[1] - y is unit distance from the bottom.
// yRange[1] - yRange[0] is the scale of the range.
// (yRange[1] - y) / (yRange[1] - yRange[0]) is the % from the bottom.
* indices are into the axes_ array.
*/
Dygraph.prototype.computeYAxes_ = function() {
+
// Preserve valueWindow settings if they exist, and if the user hasn't
// specified a new valueRange.
var i, valueWindows, seriesName, axis, index, opts, v;
this.axes_[axis] = opts;
}
+ // TODO(konigsberg): REMOVE THIS SILLINESS this should just come from DygraphOptions.
+ // TODO(konigsberg): Add tests for all of these.
+
+ // all options which could be applied per-axis:
+ var axisOptions = [
+ 'valueRange',
+ 'pixelsPerYLabel',
+ 'axisLabelFontSize',
+ ];
+
+ // Copy global axis options over to the first axis.
+ for (i = 0; i < axisOptions.length; i++) {
+ var k = axisOptions[i];
+ v = this.attr_(k);
+ if (v) this.axes_[0][k] = v;
+ }
+ // TODO(konigsberg): end of REMOVE THIS SILLINESS
+
if (valueWindows !== undefined) {
// Restore valueWindow settings.
for (index = 0; index < valueWindows.length; index++) {
// Compute extreme values, a span and tick marks for each axis.
for (var i = 0; i < numAxes; i++) {
var axis = this.axes_[i];
-
+ var logscale = this.attributes_.getForAxis("logscale", i);
+ var includeZero = this.attributes_.getForAxis("includeZero", i);
series = this.attributes_.seriesForAxis(i);
if (series.length == 0) {
maxY = Math.max(extremeMaxY, maxY);
}
}
- if (axis.includeZero && minY > 0) minY = 0;
+ if (includeZero && minY > 0) minY = 0;
// Ensure we have a valid scale, otherwise default to [0, 1] for safety.
if (minY == Infinity) minY = 0;
if (span === 0) { span = maxY; }
var maxAxisY, minAxisY;
- if (axis.logscale) {
+ if (logscale) {
maxAxisY = maxY + 0.1 * span;
minAxisY = minY;
} else {
isDate = true;
}
+ this.setXAxisOptions_(isDate);
+};
+
+Dygraph.prototype.setXAxisOptions_ = function(isDate) {
if (isDate) {
this.attrs_.xValueParser = Dygraph.dateParser;
this.attrs_.axes.x.valueFormatter = Dygraph.dateString_;
this.attrs_.axes.x.ticker = Dygraph.numericLinearTicks;
this.attrs_.axes.x.axisLabelFormatter = this.attrs_.axes.x.valueFormatter;
}
-};
+}
/**
* Parses the value as a floating point number. This is like the parseFloat()
if (Dygraph.isDateLike(data[0][0])) {
// Some intelligent defaults for a date x-axis.
this.attrs_.axes.x.valueFormatter = Dygraph.dateString_;
- this.attrs_.axes.x.axisLabelFormatter = Dygraph.dateAxisFormatter;
this.attrs_.axes.x.ticker = Dygraph.dateTicker;
+ this.attrs_.axes.x.axisLabelFormatter = Dygraph.dateAxisFormatter;
// Assume they're all dates.
var parsedData = Dygraph.clone(data);
// Some intelligent defaults for a numeric x-axis.
/** @private (shut up, jsdoc!) */
this.attrs_.axes.x.valueFormatter = function(x) { return x; };
- this.attrs_.axes.x.axisLabelFormatter = Dygraph.numberAxisLabelFormatter;
this.attrs_.axes.x.ticker = Dygraph.numericLinearTicks;
+ this.attrs_.axes.x.axisLabelFormatter = Dygraph.numberAxisLabelFormatter;
return data;
}
};
if (annotations.length > 0) {
this.setAnnotations(annotations, true);
}
+ this.attributes_.reparseSeries();
};
/**