Using chart.js in angular 8

UI Components for Angular
Post Reply
bilal_dk
Posts: 1
Joined: 29 Jul 2020, 10:53

29 Jul 2020, 10:57

i have an angular 8 application, and i'm using primeng-lts 8.2.5 components, i'm trying to use chart.js in my application, but the pie chart doesn't show up until i zoom in, also the labels, how can i refresh the chart after loading the data :

i'm loading the data from the backend like this :

<p-chart type="pie" [data]="numberByStatus ">
</p-chart>

this.numberByStatus = {
labels: [],
datasets: [
{
data: [0, 0, 0],
backgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
],
hoverBackgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
]
}]
};


this.service.getStatus()
.subscribe((res: any) => {
if (res) {
var i = 0;
res.forEach(element => {

this.service.getCountByStatus(element.id)
.subscribe((count: number) => {
if (count) {
this.numberByStatus .labels = element.name;
this.numberByStatus ['datasets'][0].data = count;
i++;
}

}, (err) => {
alert('Faild to load data');
});
});
}

}, (err) => {
alert('Faild to load StatutOperation');
});

hackup
Posts: 1
Joined: 30 Jul 2020, 19:08

30 Jul 2020, 19:12

Create a control var and display the chart after you have processed the data with ngif, that solves the problem

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests