Chartjs-Parsing JSON data into specific format for chart.js

1πŸ‘

βœ…

Is JSON.stringify() the wrong function to be using?

yes because a valid JSON is converted into a JSON string.

Instead just push the object you want to have in the array:

for (i in result) {
    var foo = {value: result[i].total, label: result[i].subcategory}
    pieData.push(foo);
}

Leave a comment