Skip to content

Commit

Permalink
Only generate ticks we care about
Browse files Browse the repository at this point in the history
Instead of cloning `me.scaleSizeInUnits` moments and probably throwing the vast majority away, only clone what we need.
  • Loading branch information
Thomas Redston authored and etimberg committed Jan 18, 2017
1 parent 312773b commit c20e57b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,15 @@ 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
if (me.options.time.max && newTick.diff(me.lastTick, me.tickUnit, true) >= 0) {
break;
}

if (i % me.unitScale === 0) {
me.ticks.push(newTick);
}
me.ticks.push(newTick);
}

// Always show the right tick
Expand Down

0 comments on commit c20e57b

Please sign in to comment.