如何在打字稿中导入highcharts离线导出

时间:2017-01-03 15:51:34

标签: angular typescript highcharts

厌倦了以下配置,但它们似乎无法正常工作。

import * as Highcharts from 'highcharts/highstock';
/*import * as HighchartsExporting from 'highcharts/modules/exporting';
HighchartsExporting(Highcharts);*/
require('highcharts/modules/offline-exporting')(Highcharts);

收到以下错误: 无法调用类型缺少调用签名的表达式。输入' {}'没有兼容的呼叫签名。

任何人都知道如何使其发挥作用。

3 个答案:

答案 0 :(得分:4)

这是一个解决方案

import * as Highcharts from 'highcharts/highstock';
import * as HighchartsExporting from 'highcharts/modules/exporting';
HighchartsExporting(Highcharts);

这足以使用,不需要单独的require命令。

答案 1 :(得分:1)

import Highcharts from 'highcharts';
import exporting from 'highcharts/modules/exporting';
exporting(Highcharts);

以上代码对我有用。

要导出,请使用chartName.exportChart()

答案 2 :(得分:0)

离线出口图表:

                   HostBuilder()
                   .ConfigureContainer<ServiceCollection>((builder, services) =>
                   {
                       var container = new Container();

                       container.RegisterSingleton<IJobRepository, JobRepository>();
                       services.AddTransient<IHostedService, TimedService>();

                   })
                   .ConfigureServices((hostContext, services) =>
                   {
                       // Originally we would have done this
                       //services.AddHostedService<Service>();
                   })
                   .Build();

        using (host)
        {
            await host.StartAsync();
            await host.WaitForShutdownAsync();
        }