我对char标签有问题。我使用它就像角度呼叫服务,他们需要在html数据中显示数据和图表。我使用最新版本的charjs(2.4.0),ng2-charts(1.5.0)angular(2.4.0)。
这是我的代码:
ngOnInit(): void {
this.getStatusChart();
}
private getStatusChart() {
this._statisticService.getStatusChart().subscribe( (response) => {
this.result = response;
this.doughnutChartDataStatus = this.result.values;
this.doughnutChartLabelsStatus = ["Open","Assigned","In progress","Complete","Close","Dismiss"];
});
}
以下是它的样子:
这是我从REST服务获得的:
data:{labels: ["'Open'", "'Assigned'", "'In progress'", "'Complete'", "'Close'", "'Dismiss'"],
values:[17, 2, 2, 0, 0, 0]}
Html模板:
<div style="display: block">
<canvas baseChart
[data]="doughnutChartDataStatus"
[labels]="doughnutChartLabelsStatus"
[chartType]="doughnutChartTypeStatus"
[legend]="doughnutChartLegend"></canvas>
</div>
如果我将labes放在setup变量中(在构造函数之前,设置为局部变量),那么它可以工作。谁能知道问题是什么?