【发布时间】:2021-07-07 03:03:02
【问题描述】:
您好,我正在关注primeng 页面上的文档。 我已经使用 npm 安装了 charts.js 包
npm install chart.js --save
App.module.ts
import {ChartModule} from 'primeng/chart';
@NgModule({
...
imports: [
...
ChartModule,
],
... })
Piechart.component.html
<h2>Members</h2>
<p-chart type="doughnut" [data]="data"></p-chart>
<p>piechart should appear here^^</p>
饼图.component.ts
data: any;
constructor() {
this.data = {
labels: ['A','B','C'],
datasets: [
{
data: [300, 50, 100],
backgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
],
hoverBackgroundColor: [
"#FF6384",
"#36A2EB",
"#FFCE56"
]
}]
};
}
根据文档,饼图应该出现,但由于某种原因它没有出现,而是留下了一个空白? scrnshot
请帮忙!!!
【问题讨论】: