Can you help me troubleshoot an issue I'm facing with creating a dataset for a line chart in Chart.js? Despite having an array of objects, the dataset isn't rendering correctly and I end up with two line charts instead of one. What could be causing this confusion?
const data = [{May 04: '', May 05: '1', May 06: ''}, {May 04: '2', May 05: '', May 06: ''}]
const chartData = {
labels: ['May 04', 'May 05', 'May 06' ],
datasets: prepareDataSet(data),
};
const prepareDataSet = (data) => {
const dataSet = [];
dataSet.push({ label: 'Total' });
data.forEach((v) => {
dataSet.push({
data: Object.values(v),
});
})
return dataSet;
};