3π
β
This will convert your data into the right format for ChartJS
function formatData(response) {
let newFormat = {
datasets: [{
data: []
}],
labels: []
};
response.result.data.forEach(item => {
newFormat.datasets[0].data.push(item.clicks);
newFormat.labels.push(item.label);
});
return newFormat;
}
Source:stackexchange.com