Skip to content

Commit

Permalink
Merge pull request #3064 from chartjs/fix/2560
Browse files Browse the repository at this point in the history
Recalculate the size of the scale in units when the end point is chan…
  • Loading branch information
etimberg committed Jul 30, 2016
2 parents 1731620 + b86e42f commit cec8d8b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scales/scale.time.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,15 @@ module.exports = function(Chart) {
// Only round the last tick if we have no hard maximum
if (!me.options.time.max) {
var roundedEnd = me.getMomentStartOf(me.lastTick);
if (roundedEnd.diff(me.lastTick, me.tickUnit, true) !== 0) {
var delta = roundedEnd.diff(me.lastTick, me.tickUnit, true);
if (delta < 0) {
// Do not use end of because we need me to be in the next time unit
me.lastTick = me.getMomentStartOf(me.lastTick.add(1, me.tickUnit));
} else if (delta >= 0) {
me.lastTick = roundedEnd;
}

me.scaleSizeInUnits = me.lastTick.diff(me.firstTick, me.tickUnit, true);
}

me.smallestLabelSeparation = me.width;
Expand Down

0 comments on commit cec8d8b

Please sign in to comment.