You need to add this at the top:
declare var require: any;
In general I suggest you install highcharts
module instead of using npm install angular2-highcharts
:
$ npm install highcharts --save
Then you can declare Highcharts like this:
declare var require: any;
let hcharts = require('highcharts');
require('highcharts/modules/exporting')(hcharts);
Here's a full example:
import { ElementRef, Component} from '@angular/core';
import { NavController } from 'ionic/angular';
declare var require: any;
let hcharts = require('highcharts');
require('highcharts/modules/exporting')(hcharts);
@Component({
selector: 'page-about',
template: `<div #myChart></div>`,
})
export class AboutPage {
@ViewChild('myChart') canvas: ElementRef;
constructor(public navCtrl: NavController) {}
ionViewDidLoad() {
let chart = hcharts.chart(this.canvas.nativeElement, {
chart: {
zoomType: 'x',
events: {
load: function() {
let self = this;
setTimeout(function(){
self.reflow();
}, 100);
}
}
},
series: [{
data: [1, 3, 2, 4]
}],
});
}
}