0👍
So a basic groupBy function ?
const data = [
{ id: '1', description: 'desc 1', number: 1 },
{ id: '2', description: 'desc 2', number: 2 },
{ id: '3', description: 'desc 2', number: 3 },
{ id: '4', description: 'desc 1', number: 4 },
{ id: '5', description: 'desc 4', number: 5 },
];
const grouped = data.reduce((p, n) => ({
...p,
[[n.description]]: (p[n.description] ?? []).concat(n)
}), {});
console.log(grouped);
- Chartjs-Two line datasets with different size (different labels) in chart.js
- Chartjs-Chart v4 : Module not found: Error: Package path . is not exported from package node_modules/chart.js
Source:stackexchange.com