From: Evert Timberg Date: Sat, 30 Jul 2016 15:06:13 +0000 (-0400) Subject: Recalculate the size of the scale in units when the end point is changed. X-Git-Tag: v2.2.1~1^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0bb2e478db7ad108591dd1fa51636797ded5d022;p=thirdparty%2FChart.js.git Recalculate the size of the scale in units when the end point is changed. --- diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 91ac3aa07..8d591b305 100755 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -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;