angular2-highcharts导入模块highcharts-more

时间:2017-02-07 08:06:48

标签: angular highcharts ionic2 angular2-highcharts

我正在使用Ionic2(v2.0.0)项目中的angular2-highcharts(v0.4.1)组件。

当我运行我的页面时,我有一个error 7 from highcharts.

我尝试在我的角度组件上添加此代码,但没有成功......

import * as Highcharts from 'highcharts';
import * as HighchartsMore from 'highcharts/highcharts-more.js';
HighchartsMore(Highcharts);

这就是......

declare var require: any;
const Highcharts = require('../../../node_modules/highcharts/highstock.src');
const HighchartsMore = require('../../../node_modules/highcharts/highcharts-more.js');
HighchartsMore(Highcharts);

有人在这个模块中添加了一些组件吗?或者知道某些库在angular2上使用highcharts?

离子信息:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v4.1.0
Xcode version: Not installed

1 个答案:

答案 0 :(得分:2)

我让它像这样工作(我使用来自npm的vanilla highcharts,而不是angular2-highcharts,所以!):

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

并在构造函数中:

HighchartsMore(Highcharts);

希望这有帮助!