【问题标题】:PrimeNG piechart not appearing in AngularPrimeNG饼图未出现在Angular中
【发布时间】: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

请帮忙!!!

【问题讨论】:

    标签: angular primeng pie-chart


    【解决方案1】:

    如果尚未添加,请将其包含在您的 angular.json 文件中:

    "architect": {
     "build": {
      //..others
      "options: {
       "scripts": [
         "node_modules/chart.js/dist/Chart.js",
         //..others
         ],
         //..others
        }
      }
      //..others
     }
    

    【讨论】:

    • 已经添加了但是还没有出现
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-06
    • 1970-01-01
    • 2021-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多