*
* A ticker is a function with the following interface:
*
- * function(a, b, pixels, pixels_per_tick, options_view, forced_values);
+ * function(a, b, pixels, options_view, dygraph, forced_values);
* -> [ { v: tick1_v, label: tick1_label[, label_v: label_v1] },
* { v: tick2_v, label: tick2_label[, label_v: label_v2] },
* ...
* millis since epoch (convertable to Date objects using "new Date(a)" and "new
* Date(b)").
*
- * pixels is the length of the axis in pixels and pixels_per_tick is the
- * minimum amount of space to be allotted to each label. For instance, if
- * pixels=400 and pixels_per_tick=40 then the ticker should return between
- * zero and ten (400/40) ticks.
- *
* opts provides access to chart- and axis-specific options. It can be used to
* access number/date formatting code/options, check for a log scale, etc.
*
+ * pixels is the length of the axis in pixels. opts('pixelsPerLabel') is the
+ * minimum amount of space to be allotted to each label. For instance, if
+ * pixels=400 and opts('pixelsPerLabel')=40 then the ticker should return
+ * between zero and ten (400/40) ticks.
+ *
* dygraph is the Dygraph object for which an axis is being constructed.
*
* forced_values is used for secondary y-axes. The tick positions are typically
return ticks;
};
+Dygraph.DEFAULT_ATTRS.axes.x.ticker = Dygraph.newDateTicker;
+Dygraph.DEFAULT_ATTRS.axes.y.ticker = Dygraph.newNumericTicks;
+Dygraph.DEFAULT_ATTRS.axes.y2.ticker = Dygraph.newNumericTicks;
pixelsPerLabel: 60,
axisLabelFormatter: Dygraph.dateAxisFormatter,
valueFormatter: Dygraph.dateString_,
- ticker: Dygraph.newDateTicker,
+ ticker: null; // will be set in dygraph-tickers.js
},
y: {
pixelsPerLabel: 30,
- valueFormatter: Dygraph.numberFormatter
+ valueFormatter: Dygraph.numberFormatter,
+ ticker: null; // will be set in dygraph-tickers.js
},
y2: {
pixelsPerLabel: 30,
- valueFormatter: Dygraph.numberFormatter
+ valueFormatter: Dygraph.numberFormatter,
+ ticker: null; // will be set in dygraph-tickers.js
}
}
};
// Add ticks. By default, all axes inherit the tick positions of the
// primary axis. However, if an axis is specifically marked as having
// independent ticks, then that is permissible as well.
- var ticker = Dygraph.newNumericTicks; // this.attr_('yTicker');
+ var opts = this.optionsViewForAxis_('y' + (i ? '2' : ''));
+ var ticker = opts('ticker');
if (i == 0 || axis.independentTicks) {
axis.ticks = ticker(axis.computedValueRange[0],
axis.computedValueRange[1],
- this.height_, // TODO(danvk): should be area.width
- this.optionsViewForAxis_('y' + (i ? '2' : '')),
+ this.height_, // TODO(danvk): should be area.height
+ opts,
this);
} else {
var p_axis = this.axes_[0];
axis.ticks = ticker(axis.computedValueRange[0],
axis.computedValueRange[1],
- this.height_, // TODO(danvk): should be area.width
- this.optionsViewForAxis_('y2'),
+ this.height_, // TODO(danvk): should be area.height
+ opts,
this,
tick_values);
}