Angular4 Highcharts TypeError 使用要求
Angular4 Highcharts TypeError using require
我正在使用 Angular4 和 angular2-highcharts。根据文档,我需要包含具有 require 属性的 highcharts 模块。它适用于包含 highcharts 模块,但不适用于附加模块(highcharts-more、highmaps 等)。当我包含更多 highcharts 模块时,我会收到如下错误:
TypeError: n is not a function
TypeError: n is not a function
at highcharts-more.js:8
at highcharts-more.js:11
我需要实现一个热图,它现在不起作用,因为它使用了额外的模块。知道如何解决这个问题吗?
这是我的 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
}
]
heatmap
系列类型不在 highcharts-more
文件中。所需的文件是 heatmap
- 如本演示所示:
如文档中所述:
https://www.highcharts.com/docs/chart-and-series-types/heatmap
我通过在 app.module.ts
中执行以下操作解决了这个问题
declare const require: any;
export function highchartsFactory() {
let Highcharts = require('highcharts');
let Heatmap = require('highcharts/modules/heatmap');
Heatmap(Highcharts);
return Highcharts;
}
我正在使用 Angular4 和 angular2-highcharts。根据文档,我需要包含具有 require 属性的 highcharts 模块。它适用于包含 highcharts 模块,但不适用于附加模块(highcharts-more、highmaps 等)。当我包含更多 highcharts 模块时,我会收到如下错误:
TypeError: n is not a function
TypeError: n is not a function
at highcharts-more.js:8
at highcharts-more.js:11
我需要实现一个热图,它现在不起作用,因为它使用了额外的模块。知道如何解决这个问题吗?
这是我的 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
}
]
heatmap
系列类型不在 highcharts-more
文件中。所需的文件是 heatmap
- 如本演示所示:
如文档中所述:
https://www.highcharts.com/docs/chart-and-series-types/heatmap
我通过在 app.module.ts
中执行以下操作解决了这个问题declare const require: any;
export function highchartsFactory() {
let Highcharts = require('highcharts');
let Heatmap = require('highcharts/modules/heatmap');
Heatmap(Highcharts);
return Highcharts;
}