I'm using chart.js@2.9.4/dist/Chart.min.js.
I have an array (data
) of objects that looks like this:
(4) […]
0: Object { Num: "5", "Label1": "6,342", "Label2": "3,051", … }
1: Object { Num: "6", "Label3": "6,247", "Label4": "3,042", … }
This array has 9 objects in it. I have another array (xLabels
) with 9 entries in it for the Y axis.
Any help would really be appreciated!
Here's what my code looks like right now:
for(i=1 ; i < Object.keys(data[0].length; i++) {
datasets.push( {
str = Object.entries(data[1])[i][1]
label: Object.entries(data[1])[i][0],
data: parseFloat(str.replace(/,/g, '.'))
})
}
new Chart(ctx, {
type: 'line',
datasets: [
{
labels: tLabels,
data: datasets,
}],
}