'Inject data from MongoDB into chart.js
I'm building a little app and I need to inject data from MongoDB which looks like this :

And there is my chart which looks like this :
labels : ['label1', 'label2', 'label3'],
datasets: [ {
data: [ 170.3, 108.75, 35.3, 37.98 ]
} ]
What I would like is :
In labels : It needs to contain all the "titre" data ( See the picture ) , if one "titre" is used more than once, it needs to display only one
In data, it needs to add every items from the "montant" ordered by category
I'm sure nobody will understand 🤪 Sorry
Example : They are 3 documents with the "titre" groceries. The "montant" are 4, 7 , 12 So the chart needs to look like this :
labels : ['Groceries', 'label2', 'label3'],
datasets: [ {
data: [ 23, ..., ... ]
} ]
How can I achieve this in the component.ts ?
Thank you everyone !
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
