angular – 如何导入highcharts-更多

前端之家收集整理的这篇文章主要介绍了angular – 如何导入highcharts-更多前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用highcharts中的spiderweb图表,这需要我更多地导入highcharts,但我无法弄清楚如何做到这一点.目前,这是我从app.module.ts向我的项目添加highcharts的方式:
import { ChartModule } from 'angular2-highcharts';
import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService';
import * as Highcharts from 'highcharts/highstock';

imports: [
    ChartModule
]

providers: [{
    provide: HighchartsStatic,useValue: Highcharts
}],

当我尝试像这样导入它时:

import * as HighchartsMore from 'highcharts/highcharts-more';

我收到以下错误

Module '"c:/pdws-view-v2/node_modules/@types/highcharts/highcharts-more"' resolves to a non-module entity and cannot be imported using this construct.

有任何想法吗?

您无需使用外部模块即可在Angular应用程序中使用highcharts或任何扩展程序包.所有你需要做的npm install –save highcharts highcharts-more然后在你的组件中以及其他导入包括
// HIGHCHARTS
import * as Highcharts from 'highcharts';
declare var require: any;
require('highcharts/highcharts-more')(Highcharts);
require('highcharts/modules/solid-gauge')(Highcharts);
require('highcharts/modules/heatmap')(Highcharts);
require('highcharts/modules/treemap')(Highcharts);
require('highcharts/modules/funnel')(Highcharts);
let chartHolder;

示例用法

ngOnInit() {
  chartHolder = Highcharts.chart('container',newOptions);
}

并且您可以更新图表选项:

updateChart(newOptions) {
  chartHolder.update(newOptions);
}
原文链接:https://www.f2er.com/angularjs/143294.html

猜你在找的Angularjs相关文章