【发布时间】:2020-05-29 22:23:54
【问题描述】:
我目前正在使用 Angular 9 和 Highcharts。
Link to the code :https://stackblitz.com/edit/angular-ivy-wdejxk
在应用程序端/测试端运行的一些说明:
-
Test - side : 在第 18 行的
angular.json文件中,更改
到"main": "src/main.ts","main": "src/main-testing.ts",
然后刷新浏览器。
-
Application - side : 与之前的完全相反。
到"main": "src/main-testing.ts","main": "src/main.ts",
以下是我遇到的一些问题:
- 我已经使用 图表回调 来获取图表实例,但它不起作用(在
hello.component.ts内, 行号 38 到 40 )。我应该如何调用它,回调实际上何时发生在 Highcharts 中? - 如果假设我能够以某种方式将图表实例分配给 chartCreated 变量。我可以控制吗
现在绘制图表,就像第 60 到 62 行一样(如果我取消注释),它会起作用吗?基本上我想
了解 Highcharts 中的
usefulness of updateFlag。 - 在
hello.component.ts内部调用 ngOnChanges 时无法添加Series - 在规范文件
hello.component.spec.ts中,我想通过输入数字数据/添加系列来测试图表 我自己,就像我在调用 onClick() 时所做的那样。但是jasmine shows error
如何解决这些?TypeError : Cannot read series of undefined TypeError : Cannot read property 'addSeries' of undefined
编辑 1 :实现 ngOnChanges 和 ngOnInit 并将大部分代码从 app.component.ts 删除到 hello.component.ts
【问题讨论】:
标签: angular typescript unit-testing highcharts karma-jasmine