【问题标题】:How to load highcharts annotations module in angular module app.module.ts?如何在角度模块 app.module.ts 中加载 highcharts 注释模块?
【发布时间】:2018-12-04 12:21:52
【问题描述】:

我正在尝试在 Angular 6 打字稿模块文件 app.module.ts 中导入 highcharts-annotations。我尝试了下面的代码,但它显示错误

“找不到模块'highcharts/module/annotations'的声明文件”

annotations.js 文件位于同一路径中,并且在控制台中显示错误

“错误类型错误:chart.addAnnotation 不是函数”。

以前有人试过吗?

代码:

import { ChartModule } from 'angular2-highcharts';

import { AnnotationsModule } from 'highcharts/modules/annotations';

import * as Highcharts from 'highcharts';

【问题讨论】:

    标签: javascript angular typescript highcharts


    【解决方案1】:

    尝试以这种方式导入模块:

    import * as AnnotationsModule from "highcharts/modules/annotations"
    

    并初始化它:

    AnnotationsModule(Highcharts);
    

    或者使用require:

    require('highcharts/modules/exporting')(Highcharts);
    

    使用我推荐的 highcharts-angular official wrapper 查看演示。

    演示: https://codesandbox.io/s/329llv6wj1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-07
      • 2015-04-02
      • 2017-05-09
      相关资源
      最近更新 更多