在Highcharts中禁用PDF和SVG下载选项 [英] Disable PDF and SVG download options in Highcharts

查看:118
本文介绍了在Highcharts中禁用PDF和SVG下载选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web应用程序中将Highcharts v4.0.3与exporting.js一起使用,我希望能够为最终用户提供以下下载选项:

I am using Highcharts v4.0.3 with exporting.js in my web app, and I want to be able to just provide the end user with the following download options:

  • 将图表下载为JPG
  • 将图表下载为PNG

但是,标准选项是:

  • 打印图表
  • 将图表下载为JPG
  • 将图表下载为PNG
  • 将图表下载为PDF
  • 将图表下载为SVG矢量图形

如何对其进行自定义,使其仅提供用户JPG和PNG选项?

How can I customise it so that it just gives the user JPG and PNG options?

推荐答案

您可以手动设置exporting.buttons.contextButton.menuItems( API )以包含所需的任何按钮.

You can manually set exporting.buttons.contextButton.menuItems (API) to contain whatever buttons you want.

您希望将其设置为仅包含JPG和PNG,如下所示(简短格式,仅textKey):

You'll want to set it to only contain JPG and PNG like this (short form, textKey only):

menuItems: ['downloadPNG','downloadJPEG']

或者用于更明确的函数调用(带有对象和onclick的长​​格式):

Or for more explicit function calls (long form with objects and onclick):

menuItems: [{
    textKey: 'downloadPNG',
    onclick: function () {
        this.exportChart();
    }
}, {
    textKey: 'downloadJPEG',
    onclick: function () {
        this.exportChart({
            type: 'image/jpeg'
        });
    }
}]

如在这些JSFiddle演示中一样:简短格式

As in these JSFiddle demonstrations: short form and long form.

exporting.js的默认值为:

menuItems: [{
    textKey: 'printChart',
    onclick: function () {
        this.print();
    }
}, {
    separator: true
}, {
    textKey: 'downloadPNG',
    onclick: function () {
        this.exportChart();
    }
}, {
    textKey: 'downloadJPEG',
    onclick: function () {
        this.exportChart({
            type: 'image/jpeg'
        });
    }
}, {
    textKey: 'downloadPDF',
    onclick: function () {
        this.exportChart({
            type: 'application/pdf'
        });
    }
}, {
    textKey: 'downloadSVG',
    onclick: function () {
        this.exportChart({
            type: 'image/svg+xml'
        });
    }
}]

export-data.js的其他内容是:

menuItems: [{
    textKey: 'downloadCSV',
    onclick: function () {
        this.downloadCSV();
    }
}, {
    textKey: 'downloadXLS',
    onclick: function () {
        this.downloadXLS();
    }
},{
    textKey: 'viewData',
    onclick: function () {
        this.viewData();
    }
},{
    textKey: 'openInCloud',
    onclick: function () {
        this.openInCloud();
    }
}]

这篇关于在Highcharts中禁用PDF和SVG下载选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆