最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Highcharts - add additional export options without losing default ones - Stack Overflow

programmeradmin1浏览0评论

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 :)

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 :)

Share Improve this question edited May 23, 2017 at 11:58 CommunityBot 11 silver badge asked Sep 30, 2013 at 10:50 Julia HaywardJulia Hayward 2,1551 gold badge15 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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/3GNZC/

发布评论

评论列表(0)

  1. 暂无评论