[Chartjs]-ChartJS is slow

1👍

The user @scx suggested to look at this page: https://www.chartjs.org/docs/latest/general/performance.html

and I might think the animation was too consumable for large amount of data, so by setting the option animation: false, this was performing better.

function PieChart(pass, fail, notRun, err, nA, percentagePassed, percentageFailed, percentageNotRun, percentageError, percentageNA) {

    window.chartColors = {
        red: '#dc3545',
        green: '#1cc88a',
        blue: '#4e73df',
        yellow: '#f6c23e',
        black: '#5a5c69'
    };

    var config = {
        type: 'pie',
        data: {
            datasets: [{
                data: [
                    nA,
                    err,
                    notRun,
                    fail,
                    pass
                ],
                backgroundColor: [
                    window.chartColors.black,
                    window.chartColors.yellow,
                    window.chartColors.blue,
                    window.chartColors.red,
                    window.chartColors.green,
                ],
                label: 'Dataset 1'
            }],
            labels: [
                percentageNA + "% NA",
                percentageError + "% Error",
                percentageNotRun + "% Not Run",
                percentageFailed + "% Failed",
                percentagePassed + "% Passed"
            ]
        },
        options: {
            parsing: false,
            normalized: true,
            animation: false
        }

    };
    window.onload = function() {
        var ctx = document.getElementById('chart-area').getContext('2d');
        window.myPie = new Chart(ctx, config);
    };
}

Leave a comment