How to populate a charts.js pie chart using json array

๐Ÿ‘:1

You can not do it that way. Here in the documentation there are some examples

One of the simple ways to set the data for a chart can be done that way:

data: {
        labels: ['Finance', 'Technique'],
        datasets: [{
            data: [1, 2],
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)'
            ],
            borderColor: [
                'rgba(255, 99, 132, 1)',
                'rgba(54, 162, 235, 1)'
            ],
            borderWidth: 1
        }]
    },

Working fiddle example

Leave a comment