PrimeNG Bar chart model with Spring boot API

UI Components for Angular
Post Reply
youssefboudaya
Posts: 2
Joined: 29 Jul 2021, 21:09

03 Aug 2021, 16:05

I have a Spring boot web service that returns:

Code: Select all

[
    {
        "status_counts": [
            {
                "status": "FAILURE",
                "count": 1
            },
            {
                "status": "SUCCESS",
                "count": 1
            }
        ],
        "month": 8
    }
    ]
This is my TS code that consumes that webservice:

Code: Select all

data_monthly: { datasets: any[], labels: any[] } = { datasets: [], labels: [] };
    
    this.dashboardService.getStatByProjectIdByMonth(this.id).subscribe((data) => {
      this.data_monthly = {
        datasets: [
          data.map(a => a.status_counts.forEach(obj => {
          {
            label => obj.status;
            data =>  obj.count;
            backgroundColor =>  '#42A5F5';
        }
      }))],
        labels: data.map(a => a.month)
      };
    });
The chart is displayed like this:
Image

I debugged in my opera console and i'm sure that the data is received in getStatByProjectIdByMonth.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 19 guests