[Chartjs]-Plotting objects in Chart.js

1👍

Use Object.keys() and Object.values()

Those functions are self explanatory

var data = [{"A":"40","B":"37","C":"31.5"}]

// If you know the property key you want to delete use 
// delete data[0]["A"]

//If you dont know it 
//delete data[0][Object.keys(data[0])[0]]

var labels = Object.keys(data[0]);
var dataset = Object.values(data[0])

console.log("labels: ", labels)

console.log("dataset: ", dataset)

Leave a comment