Half Blood Prince
Half Blood Prince

Reputation: 1111

Control HighCharts export options

I am using HighCharts. Now just by importing exporting.js file I get all the format for exporting like png, jpeg, PDF, SVG, CSV and EXCEL. What should I do to restrict some options? Like if I want only export to excel functionality how do I restrict other options?

Thanks in advance.

Upvotes: 0

Views: 5218

Answers (3)

IsraGab
IsraGab

Reputation: 5185

In your HTML:

<button type="button" class="btn btn-default" data-type="application/vnd.ms-excel">XLS</button>

You can use exportChartLocal:

 $('#exportExcel').click(function(){
      var chart = $('#example-1').highcharts();
      chart.exportChartLocal({ type: 'application/vnd.ms-excel' });
});

Check this FIDDLE

Upvotes: 1

Deepak Agrawal
Deepak Agrawal

Reputation: 121

exporting: {
    buttons: {
          contextButton{
              menuItems:['printChart', 'downloadPNG', 'downloadCSV', 'downloadXLS']
          }
        }
      }

You can get more menu items from this link to suit your needs --> https://api.highcharts.com/highcharts/exporting.buttons.contextButton.menuItems

Upvotes: 1

Paweł Fus
Paweł Fus

Reputation: 45079

You can get default options this way:

var options = Highcharts.getOptions().exporting.buttons.contextButton.menuItems;

Now, simply modify that array:

options.splice(4, 1); // remove PDF

And use in options:

exporting: {
  buttons: {
    contextButton: {
      menuItems: options
    }
  }
},

Demo: http://jsfiddle.net/pscjzhe4/283/

Upvotes: 2

Related Questions