我在我的angular 9
应用程序中实现了chart js
。预期的图表值没有出现。
ngOnInit:
ngOnInit(): void {
this.smdashboardservice.fetchSmDashboardData().subscribe(response=>{
//let data = response.data
let data = [
{"label":"Application","sublabel":"Nice","count":2},
{"label":"Application","sublabel":"poor","count":1},
{"label":"Channels","sublabel":"Quality","count":2},
{"label":"Customer Care","sublabel":"support","count":2}
]
this.barChartLabels = Object.keys(data);
this.barChartLabels.forEach(label => {
this.barChartData[0].data.push(data[label]['count']);
});
})
}
当前赋码图
但我期待着这样
1条答案
按热度按时间zwghvu4y1#
您需要准备对
sublabel
进行分类的数据集。每个数据集应包含x轴类别长度为(
label
)的值,即3。Demo @ StackBlitz
备选方案:
subLabelDatasets
可以简化为: