使用来自http请求的数据创建饼图,但数据永远不会在饼图中呈现
我试过了
在html中
<div class="col-md-4" *ngIf="overallready">
<chart [options]="overallinsp" class="chart"></chart>
</div>
我有打字稿代码
this._reportService.getOverview(utctime:number) //performs http request
.subscribe(
let dtaval = JSON.parse(JSON.stringify(res.totalinspectiondata));
console.log(dtval)
this.overallinsp = {
credits: {
enabled: false
},
chart: {
...
type: 'pie'
},
title: {
text: ...
},
series: [{
name: 'Brands',
colorByPoint: true,
data:dtval
}]
}
this.overallready = true;
)
上面的console.log()生成
[{"name":"Bulker delivered","y":0},{"name":"Normal delivered truck","y":4}]
在
系列作品中手动设置值 series: [{
name: 'Brands',
colorByPoint: true,
data:[{"name":"Bulker delivered","y":0},{"name":"Normal delivered truck","y":4}]
}]
由于手动设置数据输出有效但引用它无法正常工作会出现什么问题?