Dygraph.dateTicker = function(a, b, pixels, opts, dygraph, vals) {
- var pixels_per_tick = opts('pixelsPerLabel');
- var chosen = -1;
- for (var i = 0; i < Dygraph.NUM_GRANULARITIES; i++) {
- var num_ticks = Dygraph.numDateTicks(a, b, i);
- if (pixels / num_ticks >= pixels_per_tick) {
- chosen = i;
- break;
- }
- }
+ var chosen = Dygraph.pickTickGranularity(a, b, pixels, opts);
if (chosen >= 0) {
return Dygraph.getDateAxis(a, b, chosen, opts, dygraph);
return vals;
}();
+Dygraph.pickTickGranularity = function(a, b, pixels, opts) {
+ var pixels_per_tick = opts('pixelsPerLabel');
+ for (var i = 0; i < Dygraph.NUM_GRANULARITIES; i++) {
+ var num_ticks = Dygraph.numDateTicks(a, b, i);
+ if (pixels / num_ticks >= pixels_per_tick) {
+ return i;
+ }
+ }
+ return -1;
+};
+
Dygraph.numDateTicks = function(start_time, end_time, granularity) {
if (granularity < Dygraph.MONTHLY) {
// Generate one tick mark for every fixed interval of time.