Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts - add additional export options without losing default ones

I'm trying to add an export-to-csv option to a Highcharts chart, without actually removing all the default options (print, PNG, JPG, PDF, SVG export). The solution offered in Highcharts add export as csv results in the existing options being blown away, as does trying to use the Exporting class in DotNet.Highcharts. Is there a way to achieve this?

NB: I can see how to achieve what I want by editing exporting.js, but that's not a desirable way to go about it :)

like image 368
Julia Hayward Avatar asked Feb 16 '23 03:02

Julia Hayward


1 Answers

You can add the new item to the menu right after you define the chart:

Highcharts.getOptions().exporting.buttons.contextButton.menuItems.push({
    text: 'My new button',
    onclick: function () {
        alert('OK');
    }
});

This will keep the default items.

Demo: http://jsfiddle.net/3GNZC/

like image 193
melancia Avatar answered Feb 18 '23 12:02

melancia