]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Only generate ticks we care about
authorThomas Redston <tlr@corefiling.com>
Fri, 13 Jan 2017 17:55:28 +0000 (17:55 +0000)
committerEvert Timberg <evert.timberg+github@gmail.com>
Wed, 18 Jan 2017 02:13:09 +0000 (21:13 -0500)
Instead of cloning `me.scaleSizeInUnits` moments and probably throwing the vast majority away, only clone what we need.

src/scales/scale.time.js

index 61796c6ebcc634c0d058bea63b610ed661945ee5..9a3e31e63b379a80150cf2c23e5239aa83ef27e2 100755 (executable)
@@ -324,7 +324,7 @@ module.exports = function(Chart) {
                        me.ticks.push(me.firstTick.clone());
 
                        // For every unit in between the first and last moment, create a moment and add it to the ticks tick
-                       for (var i = 1; i <= me.scaleSizeInUnits; ++i) {
+                       for (var i = me.unitScale; i <= me.scaleSizeInUnits; i += me.unitScale) {
                                var newTick = roundedStart.clone().add(i, me.tickUnit);
 
                                // Are we greater than the max time
@@ -332,9 +332,7 @@ module.exports = function(Chart) {
                                        break;
                                }
 
-                               if (i % me.unitScale === 0) {
-                                       me.ticks.push(newTick);
-                               }
+                               me.ticks.push(newTick);
                        }
 
                        // Always show the right tick