Disable PDF and SVG download options in Highcharts

前端 未结 3 1705
不知归路
不知归路 2021-02-15 18:36

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:

  • Download Char
3条回答
  •  忘了有多久
    2021-02-15 19:01

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

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

    menuItems: ['downloadPNG','downloadJPEG']
    

    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'
            });
        }
    }]
    

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

    The default for exporting.js is:

    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'
            });
        }
    }]
    

    The additional ones for export-data.js are:

    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();
        }
    }]
    

提交回复
热议问题