在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]
});
1条答案
按热度按时间kuhbmx9i1#
只需安装此软件包
@types/chart.js
:npm i -D @types/chart.js
它会解决这个问题