Reputation: 255
I'm making use of Angular4 and angular2-highcharts. According to the documentation I need to include the highcharts modules with the require attribute. It worked fine for including the highcharts module, but not with the additional modules (highcharts-more, highmaps etc.). When I include more module of highcharts I get errors like:
TypeError: n is not a function
TypeError: n is not a function
at highcharts-more.js:8
at highcharts-more.js:11
I need to implement a heatmap, which is not working now, because it makes use of the extra modules. Any idea how to solve this?
Here is my code for app.module.ts
// solution for angular not picking up required attribute
declare const require: any;
export function highchartsFactory() {
let hc = require('highcharts');
let hex = require('highcharts/modules/exporting');
let hmod = require('highcharts/highcharts-more');
hex(hc);
hmod(hex);
return hc;
}
imports: [
ChartModule,
],
providers: [
{
provide: HighchartsStatic,
useFactory: highchartsFactory
}
]
Upvotes: 2
Views: 574
Reputation: 255
I solved this problem by doing the following in app.module.ts
declare const require: any;
export function highchartsFactory() {
let Highcharts = require('highcharts');
let Heatmap = require('highcharts/modules/heatmap');
Heatmap(Highcharts);
return Highcharts;
}
Upvotes: 1
Reputation: 7896
The heatmap
series type is not in the highcharts-more
file. The required file is heatmap
- as shown in this demo:
and as explained in doc here:
https://www.highcharts.com/docs/chart-and-series-types/heatmap
Upvotes: 0