[Chartjs]-ChartJS Everything under one label?

1👍

This is happening because you make new datasets instead of adding to a dataset. Each dataset is its own circle. If you change your addData function and chart instantiation to the following it will work as expected:

var racionChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
        labels: [],
        datasets: [{
            label: 'text that appears in the legend',
            data: [],
            backgroundColor: []
        }]
    },
    // Configuration options go here
    options: {
        plugins: {
            title: {
                display: true,
                fontSize: 16,
                text: 'Racion Mix'
            },
        }
    }
});

function addData(label, value, color) {
    this.racionChart.data.labels.push(label);
    this.racionChart.data.datasets[0].data.push(value);
    this.racionChart.data.datasets[0].backgroundColor.push(color);
    this.racionChart.update();
}

Leave a comment