[Chartjs]-Chartjs โ€“ onAnimationComplete fires before the animation actually completes

11๐Ÿ‘

โœ…

I think you did not define an animation. Try this example found at Chart.js documentation.

var scanedTodayChart = new Chart(scanedTodayChartCtx, {
    type: 'pie',

    data: {
        labels: [
            "Red",
            "White",
        ],
        datasets: [
        {
            data: [10, 100],
            backgroundColor: [
                "#DA1A32",
                "#F0FFFF"
            ],
            borderWidth: false,
            borderColor: false
        }]
    },
    options: {
        cutoutPercentage: 90,
        animation: {
            duration: 2000,
            onProgress: function(animation) {
                $progress.attr({
                    value: animation.animationObject.currentStep / animation.animationObject.numSteps,
                });
            },
            onComplete: function(animation) {
                alert('onAnimationComplete')
            }
        }
    },
    borderColor: '#DA1A32',
    fullWidth: true,
});

Leave a comment