gpt4 book ai didi

highcharts - angular2-highcharts Highcharts 导出模块

转载 作者:太空狗 更新时间:2023-10-29 19:35:29 28 4
gpt4 key购买 nike

如何将导出模块包含到 angular2 应用程序中?

我尝试将以下脚本添加到 index.html 但没有任何反应。

<script src="http://code.highcharts.com/modules/exporting.js"></script>

最佳答案

从 Angular CLI 1.0-RC.1 和最新的 angular2-highcharts 开始,这对我有用(另请参阅关于推荐解决方案的持续讨论 https://github.com/gevgeny/angular2-highcharts/issues/156):

npm install --save angular2-highcharts 
npm install --save @types/highcharts

在 typings.d.ts 中添加:declare var require: any;

然后在 app.module.ts 中:

import { ChartModule } from 'angular2-highcharts';
import {HighchartsStatic} from 'angular2-highcharts/dist/HighchartsService';
export function highchartsFactory() {
var hc = require('highcharts');
var hcm = require('highcharts/highcharts-more');
var exp = require('highcharts/modules/exporting');

hcm(hc);
exp(hc);
return hc;
}

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ChartModule
],
providers: [{provide: HighchartsStatic, useFactory: highchartsFactory}],
bootstrap: [AppComponent]
})
export class AppModule { }

早期版本的旧答案:

如果您使用 angular-cli (webpack) 和 angular2-highcharts,这对我有用:

import {Highcharts} from 'angular2-highcharts';
require('highcharts/modules/exporting')(Highcharts);

关于highcharts - angular2-highcharts Highcharts 导出模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38742480/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com