Can’t display my data separately on chartjs

I've been trying to make a barchart to display the data:

var ctx2 = document.getElementById('2').getContext('2d');
    var myChart2 = new Chart(ctx2, {
        type: 'bar',
        data: {
            labels: ["City 1", "City 2", "City 3", "City 4", "City 5"],
            datasets: [{
                label: cps,
                data: cpscli,
                backgroundColor: 'rgba(54, 162, 235, 1)',
                borderColor: 'rgba(54, 162, 235, 1)',
                
            }, {
                label: ht,
                backgroundColor: 'rgba(255, 99, 132, 1)',
                borderColor: 'rgba(255, 99, 132, 1)',
                data: htcli,
            },
            {
                label: art,
                backgroundColor: 'rgba(255, 206, 86, 1.0)',
                borderColor: 'rgba(255, 206, 86, 1)',
                data: artcli,
            },
            {
                label: val,
                backgroundColor: 'rgba(75, 192, 192, 1.0)',
                borderColor: 'rgba(75, 192, 192, 1)',
                data: valcli,
            },
            {
                label: vin,
                backgroundColor: 'rgba(255, 159, 64, 1.0)',
                borderColor: 'rgba(255, 159, 64, 1)',
                data: vincli,
            }],
        },
        options: {
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero: true
                    }
                }]
            }
        }
    });
}

but when the chart is displayed, all the data its in the first column like this: enter image description here

it was supposed to be one per column, could someone help me out?



Read more here: https://stackoverflow.com/questions/67389729/cant-display-my-data-separately-on-chartjs

Content Attribution

This content was originally published by Raul Nóbrega de Souza at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: