]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Ensure tickUnit and displayFormat set before format loop
authorTanner Linsley <tannerlinsley@gmail.com>
Tue, 29 Sep 2015 16:54:42 +0000 (10:54 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Tue, 29 Sep 2015 16:54:42 +0000 (10:54 -0600)
src/scales/scale.time.js

index e885b9ee9f863c21f43078f57c230dd847623d8c..9ba486ce42297057815110a56cb4ed6f25010d16 100644 (file)
                                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;