我有一个动态图表生成组件,基于收到的数据。我在组件内部创建了一个图表实例并填写了属性。我将chartjs-annotate-plugin导入为
import * as annotation from 'chartjs-plugin-annotation';
并注册图表插件,如下所示:
constructor(){
Chart.pluginService.register(annotation);
}
我试图在图表实例化之前移动它,但有趣的是我看到了注释,它只是导致控制台错误,说注释不是ChartOptions上的属性。
任何想法?
这是我的错误:
ERROR in src/app/shared/charts/chart/chart.component.ts(143,11): error
TS2345: Argument of type '{ plugins: any[]; type: string; data: { labels:
any[]; datasets: any[]; }; options: { scales: { y...' is not assignable to
parameter of type 'ChartConfiguration'.
Types of property 'options' are incompatible.
Type '{ scales: { yAxes: { stacked: boolean; ticks: { beginAtZero: true;
callback: (value: any, index: ...' is not assignable to type
'ChartOptions'.
Object literal may only specify known properties, and 'annotation' does
not exist in type 'ChartOptions'.