尝试脱机导出到Highcharts

bvuwiixz  于 2022-11-11  发布在  Highcharts
关注(0)|答案(3)|浏览(176)

我想用highcharts做离线导出。这是我的代码

import {Chart} from 'highcharts-vue'
import Highcharts from 'highcharts'
import offlineExporting from "highcharts/modules/offline-exporting"
offlineExporting(Highcharts)

我试着同时使用exporting.js和offline-exporting.js,并且成功了。这是问题的解决方案吗?如果不是,还有其他的解决方案吗?

dluptydi

dluptydi1#

要使用offline-exporting模块,您还需要导入exporting模块。
此外,还可以禁用fallbackToExportServer属性,以便导出时永远不使用Highcharts导出服务器。

exporting: {
    ...,
    fallbackToExportServer: false
},

美国石油学会:

回退到导出服务器:布尔值

如果脱机导出模块无法在客户端导出图表,是否回退到导出服务器。
...

现场演示:https://jsfiddle.net/BlackLabel/92dbwLgx/
API引用:https://api.highcharts.com/highcharts/exporting.fallbackToExportServer
文件:https://www.highcharts.com/docs/export-module/client-side-export

nzk0hqpo

nzk0hqpo2#

您需要将“exporting.fallbackToExportServer”设置为等于“false”,以便始终将图表导出到本地。
http://jsfiddle.net/viethien/rcmpbsL1/
第一个

u4vypkhs

u4vypkhs3#

对于offline-exporting,您必须进行客户端导出实现

import { withHighcharts } from 'react-jsx-highcharts';
import Highcharts from 'highcharts';
import exportingOption from 'highcharts/modules/exporting';
import offlineOption from 'highcharts/modules/offline-exporting';

exportingOption(Highcharts);
offlineOption(Highcharts);

withHighcharts(Component, Highcharts);

此外,您必须添加导出对象为Highcharts选项

exporting: {
    buttons: {
        contextButton: {
            menuItems: ['downloadPNG', 'downloadJPEG', 'downloadPDF', 'downloadSVG']
        }
    }
}

相关问题