[Chartjs]-Chart.js on animation end callback

3πŸ‘

βœ…

There is an onAnimationComplete option you can specify to run stuff once the animation completes. See this section of the documentation.

Example

var ctx = document.getElementById("chart").getContext("2d");
var myLine1 = new Chart(ctx).Line(lineChartData1, {
    onAnimationComplete: function() {
        alert('animation complete')
    }
});

Fiddle – http://jsfiddle.net/4vo72rLd/

8πŸ‘

For Chart.Js 2.6.0

options: {
    cutoutPercentage: 90,
    animation: {
        duration: 2000,
        onProgress: function(animation) {
            $progress.attr({
                value: animation.animationObject.currentStep / animation.animationObject.numSteps,
            });
        },
        onComplete: function(animation) {
            alert('onAnimationComplete')
        }
    }
},

See this codepen https://codepen.io/shivabhusal/pen/XaZQaW

Leave a comment