ChartsModule
哪些参考文献
Chart.js
. 我有
图表.js
已安装并已将其导入我的
angular.json
"scripts": [
"node_modules/chart.js/dist/Chart.bundle.min.js"
]
应用程序都正常工作,并显示图表。但是,我的组件测试出现以下错误:
ReferenceError: Chart is not defined
我看过几篇建议进口的文章图表.js我的组件测试如下:
import { Chart } from 'chart.js';
这不管用。我的问题是,导入第三方JS库(如图表.js进入6个业力测试
编辑
我的组件
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-my-chart',
templateUrl: './my-chart.component.html',
styleUrls: ['./my-chartcomponent.scss']
})
export class MyChartComponent implements OnInit {
public data: any;
constructor() { }
ngOnInit() {
this.data = {
labels: ['Low', 'Medium', 'High'],
datasets: [
{
data: [300, 50, 10],
backgroundColor: [
'#43a047',
'#fb8c00',
'#e53935'
],
hoverBackgroundColor: [
'#66bb6a',
'#ffa726',
'#ef5350'
]
}]
};
}
}