Chartjs-Chart.data.datasets.push() also adds datasets to other charts in array

0👍

Fixed! I had 2 variables for initial data and options that is set to each chart upon creation. Everytime each chart is manipulated, the updates carry on to the other charts since they were initialized with the same initial variable 😉

    var defaultData = {labels: [], datasets: []};
    var defaultOptions = {};

    function addDataset(){
        chartArray.push(new Chart(ctx, {type: 'bar',
            data: defaultData,       //these two
            options: defaultOptions, //were causing the problem
        }));
    }

Leave a comment