0👍
As stated in the comments, the labels will be an array of your data
elements stat_name
property and there will be a data set for each entry of your data
. You can clean much of the processing of the data
into the below:
const chartdata = {
labels: data.map(item => item.stat_name),
datasets: data.map(item => ({ data: item.stat_count }));
};
Source:stackexchange.com