Create an array for Chartjs with Firestore + Angular 9 data

Asked

Viewed 31 times

0

To popular a precise monthly/annual data chart that the Array is grouped by date.

Data from the Firestore:

this.chartsSrv.chartGeral().subscribe((snapshot) => {
  snapshot.docs.forEach(doc => {
    let item = doc.data();
    this.dataArray.push({
      "id": item.id,
      "dataPost": moment(item.dataPost.toDate()).format('DD/MM/YYYY')
    });
  })
})

console.log(this.dataArray);

inserir a descrição da imagem aqui

The chart requires 3 information according to the following formats.

Pico: It switches as the maximum value of the length property of the array you would need to create.

Months: [Jan, Feb, Mar ... ] according to the values that come from each array group in the dataPost item

Total per Month: then enters the question that I need to group by date and take the length property of each group.

To illustrate: inserir a descrição da imagem aqui

  • Okay, what have you tried?

  • @veroneseComS tried this answer but unsuccessfully https://answall.com/questions/342198/l%C3%b3gica-para-agrupar-dados-em-array-javascript? Rq=1

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.