Reputation: 199
i fill the pie chart data using api i fill the data successfully but label data is undefined
this is my ts file
let arrayLabel =[];
let arrayData = [];
for (let index = 0; index < this.responseData.length; index++) {
// this.asset_category = this.responseData[index].asset_category;
// this.asset_value = this.responseData[index].asset_value;
// this.asofdate = this.responseData[index].asofdate;
arrayLabel.push(this.responseData[index].asset_category);
arrayData.push( this.responseData[index].asset_value);
}
console.log(arrayLabel);
console.log(arrayData);
this.pieChartLabels = [arrayLabel] ;
this.pieChartData = [arrayData];
this is my html file
<div style="display: block" *ngIf='pieChartData'>
<canvas baseChart #baseChart
[data]="pieChartData"
[labels]="pieChartLabels"
[chartType]="pieChartType"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas>
</div>
i also attach the screen shot when i click on pink color than display all the label name.when i click on other part of label display undefined
Upvotes: 1
Views: 574
Reputation: 593
Try this:
this.pieChartLabels = arrayLabel;
...instead of:
this.pieChartLabels = [arrayLabel] ;
Upvotes: 3