This is more a TypeScript issue probably but I’m trying to get Ionic 2 to work with Highcharts modules. So getting Highcharts to work wasn’t a problem using the angular2-highcharts project (link) but now there is an issue with the modules of highcharts. The angular2-highcharts project makes use of a d.ts file for highcharts, but it seems like the modules of highcharts (which are included in the package just in /modules folder) are not included in this definition. The modules are also available as separate packages. Angular2-highcharts lists a way to load modules but I can’t seem to get it to work with Ionic 2. In the Plunker it works, but that seems to be using SystemJS. Am I missing something here?
Yes, highcharts works very well but the modules don’t :). This isn’t really an Ionic problem. There is no TypeScript definition for the module js files. I solved this issue by editing the module js file to expose it as a globally accessible object.
Hi, I have same problem with you. I wanna put 3d charts in my project, but angular2 can not find ‘highcharts/highcharts-3d’ module. Could you explain more specific?
Hi you Can directly install highcharts module using npm (npm install highcharts --save ) Install from npm instead of using npm install angular2-highcharts --save
declare it like
declare var require: any;
var hcharts = require(‘highcharts’);
require(‘highcharts/modules/exporting’)(hcharts);
use object > hcharts
var chart = hcharts.chart(this.canvas.nativeElement, {
//chart
}):
Hi , am doing almost the same thing as you here but i keep getting the error inline template:45:10 caused by: Cannot read property 'nativeElement' of undefined
Also, constructor is too soon for ViewChild to resolve, I think it will work if you, e.g. move it to a downstream lifecycle event, like ngOnInit, that fires after the component template is rendered.
create instance of hichart ( this.graph = Highcharts.chart(this.chartElement.nativeElement, this.chartOptions); ) in somlifecycle events eg. in ngAfterViewInit() as I have done above