diff --git a/src/core/core.animations.js b/src/core/core.animations.js index fd0aa877a3b..85edf720f4f 100644 --- a/src/core/core.animations.js +++ b/src/core/core.animations.js @@ -93,21 +93,24 @@ module.exports = { */ advance: function() { var animations = this.animations; - var animation, chart, nextStep; + var animation, chart, steps, nextStep; var i = 0; + // 1 animation per chart, so we are looping charts here while (i < animations.length) { animation = animations[i]; chart = animation.chart; + steps = animation.numSteps; - nextStep = (animation.currentStep || 0) + 1; - animation.currentStep = Math.floor((Date.now() - animation.startTime) / animation.duration * animation.numSteps); - animation.currentStep = Math.min(Math.max(nextStep, animation.currentStep), animation.numSteps); + // Make sure that currentStep starts at 1 + // https://github.com/chartjs/Chart.js/issues/6104 + nextStep = Math.floor((Date.now() - animation.startTime) / animation.duration * steps) + 1; + animation.currentStep = Math.min(nextStep, steps); helpers.callback(animation.render, [chart, animation], chart); helpers.callback(animation.onAnimationProgress, [animation], chart); - if (animation.currentStep >= animation.numSteps) { + if (animation.currentStep >= steps) { helpers.callback(animation.onAnimationComplete, [animation], chart); chart.animating = false; animations.splice(i, 1);