ionic/angular应用程序编译错误中的chart.js 我的目标
我正试图画一个简单的带有目标线的条形图 总结我的问题 安装/使用ng2图表对于柱状图本身来说似乎没问题,但我正在努力让它在编译时不会出错 问题的细节 我过去常常开始 上图是条形图,可根据需要工作。我在关联页面的typescript文件中使用以下代码段实现了这一点:ionic/angular应用程序编译错误中的chart.js 我的目标,angular,typescript,ionic-framework,ng2-charts,Angular,Typescript,Ionic Framework,Ng2 Charts,我正试图画一个简单的带有目标线的条形图 总结我的问题 安装/使用ng2图表对于柱状图本身来说似乎没问题,但我正在努力让它在编译时不会出错 问题的细节 我过去常常开始 上图是条形图,可根据需要工作。我在关联页面的typescript文件中使用以下代码段实现了这一点: barChartLabels: Label[] = ['']; barChartType: ChartType = 'horizontalBar'; barChartPlugins = []; barChartLeg
barChartLabels: Label[] = [''];
barChartType: ChartType = 'horizontalBar';
barChartPlugins = [];
barChartLegend = false;
barChartData: ChartDataSets[] = [
{ data: [450], label: 'Forecast', backgroundColor: 'rgb(0,75,190)', barThickness: 50 },
{ data: [750], label: 'Invoiced', backgroundColor: 'rgb(0,200,200)', barThickness: 50 },
{ data: [1250], label: 'Received', backgroundColor: 'rgb(0,200,100)', barThickness: 50 },
];
到目前为止,一切顺利。但现在我想在任意点画一条垂直线,比如2400。我正在尝试使用,所以我必须包括
import * as pluginAnnotations from 'chartjs-plugin-annotation';
在文件顶部,然后将其包括在图表选项中:
barChartLabels: Label[] = [''];
barChartType: ChartType = 'horizontalBar';
barChartPlugins = [pluginAnnotations]; <<<<<<<<
barChartLegend = false;
barChartData: ChartDataSets[] = [
{ data: [450], label: 'Forecast', backgroundColor: 'rgb(0,75,190)', barThickness: 50 },
{ data: [750], label: 'Invoiced', backgroundColor: 'rgb(0,200,200)', barThickness: 50 },
{ data: [1250], label: 'Received', backgroundColor: 'rgb(0,200,100)', barThickness: 50 },
];
我已经安装了带有
npm install chartjs-plugin-annotation
我建议您对
Plugin
和Chartjs
都使用CDN
;你能再说一点吗?为什么使用CDN?它如何解决这个问题?谢谢。因为它通过CDN在我的项目中工作。我认为ng2图表没有更新,而cdn可以使用最新版本的chatjs。
npm install chartjs-plugin-annotation