From: Tanner Linsley Date: Tue, 29 Sep 2015 16:54:42 +0000 (-0600) Subject: Ensure tickUnit and displayFormat set before format loop X-Git-Tag: 2.0.0-alpha4~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e24406fc9da96889c83d2d25e76f74bf63abb4ba;p=thirdparty%2FChart.js.git Ensure tickUnit and displayFormat set before format loop --- diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index e885b9ee9..9ba486ce4 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -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;