找不到名称'ChartOptions'

bmvo0sr5  于 2023-03-12  发布在  Chart.js
关注(0)|答案(1)|浏览(152)

在Angular中,我使用“chart.js”:“^3.9.1”,获取错误
ERROR in node_modules/chart.js/types/adapters.d.ts:1:15 - error TS2304: Cannot find name 'ChartOptions'.
尝试在chart js中使用数据标签,但我必须从“chart.js/auto”导入图表;

let myChart = new Chart(this.ctx, {
      type: 'bar',
      data: {
        labels: number,
        datasets:  [{
          categoryPercentage: 1,
        label: "IncomingCalls",
        data: callsReceived,
        borderColor: '#4c8ffb',
        backgroundColor: '#4c8ffb',
        borderWidth: 2,
        barThickness: 50},
        {
          categoryPercentage: 1,
        label: "OutgoingCalls",
        data:callmade,
        borderColor: '#58e395',
        backgroundColor: '#58e395',
        borderWidth: 2,
        barThickness: 50}],
          
      },

      options:{
      scales: {
          xaxis:{
            stacked:true,
          },
        
        
      } ,
      plugins: {
        //  datalabels:{
        //    formatter:(value , ctx)=>{
        //      console.log(ctx.chart.data);
        //    }
        //  },

        title: {
            display: true,
            text: this.graphTitle
        }
    }
       },
//plugins:[chartDataLabels]
    });
kuhbmx9i

kuhbmx9i1#

只需安装此软件包@types/chart.js
npm i -D @types/chart.js
它会解决这个问题

相关问题