找不到名称'ChartOptions'

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

在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”导入图表;

  1. let myChart = new Chart(this.ctx, {
  2. type: 'bar',
  3. data: {
  4. labels: number,
  5. datasets: [{
  6. categoryPercentage: 1,
  7. label: "IncomingCalls",
  8. data: callsReceived,
  9. borderColor: '#4c8ffb',
  10. backgroundColor: '#4c8ffb',
  11. borderWidth: 2,
  12. barThickness: 50},
  13. {
  14. categoryPercentage: 1,
  15. label: "OutgoingCalls",
  16. data:callmade,
  17. borderColor: '#58e395',
  18. backgroundColor: '#58e395',
  19. borderWidth: 2,
  20. barThickness: 50}],
  21. },
  22. options:{
  23. scales: {
  24. xaxis:{
  25. stacked:true,
  26. },
  27. } ,
  28. plugins: {
  29. // datalabels:{
  30. // formatter:(value , ctx)=>{
  31. // console.log(ctx.chart.data);
  32. // }
  33. // },
  34. title: {
  35. display: true,
  36. text: this.graphTitle
  37. }
  38. }
  39. },
  40. //plugins:[chartDataLabels]
  41. });
kuhbmx9i

kuhbmx9i1#

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

相关问题