【发布时间】:2018-07-25 06:31:02
【问题描述】:
我正在尝试使用 xrange 类型的 HighCharts:
import { ChartModule } from 'angular2-highcharts';
import * as highcharts from 'highcharts';
import { HighchartsStatic } from '../../../../node_modules/angular2-highcharts/dist/HighchartsService';
export function highchartsFactory() {
const hc = require('highcharts');
const dd = require('highcharts/modules/xrange');
dd(hc);
return hc;
}
@NgModule({
imports: [
/* case 1 */
ChartModule
// in this case the code compiles but I get Error 17 in console
/* case 2 */
/* ChartModule.forRoot(require('highcharts'), require('highcharts/modules/xrange')) */
// in this case the code doesn't compiles with the error:
// "Error encountered resolving symbol values statically.
// Calling function 'ChartModule', function calls are not supported."
],
providers: [
{
provide: HighchartsStatic,
useValue: highcharts,
useFactory: highchartsFactory
}
})
如这两种情况所示,我在创建图表时遇到了问题。有人告诉我,第一种情况是更好的方法,我想继续朝这个方向发展。
我看到很多帖子都使用这种方法,但都没有提到这个错误。
【问题讨论】:
-
使用官方 highcharts npm 检查这个实现stackblitz.com/edit/angular4-highcharts-x-range?file=app/…
-
你安装了 highchart typings 吗?
-
我得到错误:
xrange_1.default is not a function TypeError: xrange_1.default is not a function@Deep 3015 -
是的,我安装了 highchart @ Chellappan
-
@AmichayAtias 你使用的是官方的 highcharts npm 而不是 angular2-highcharts
标签: angular highcharts