Ensure tickUnit and displayFormat set before format loop

This commit is contained in:
Tanner Linsley 2015-09-29 10:54:42 -06:00
parent 4c79c5756f
commit e24406fc9d

View File

@ -103,9 +103,12 @@
var labelCapacity = innerWidth / this.options.ticks.fontSize + 4;
var buffer = this.options.time.round ? 0 : 2;
this.tickRange = Math.ceil(this.lastTick.diff(this.firstTick, true) + buffer);
var done;
// Start as small as possible
this.tickUnit = 'millisecond';
this.tickRange = Math.ceil(this.lastTick.diff(this.firstTick, this.tickUnit, true) + buffer);
this.displayFormat = time.unit[this.tickUnit].display;
// Work our way up to comfort
helpers.each(time.units, function(format) {
if (this.tickRange <= labelCapacity) {
return;