Custom Highcharts Context Menu Button Appearing in Every Chart on Page
highcharts, javascript
Solution
To add button use options for chart. Then you can set for each chart different set of options: http://jsfiddle.net/4uP5y/4/
Get default buttons:
var buttons = Highcharts.getOptions().exporting.buttons.contextButton.menuItems;
buttons.push({
text: "Tokyo Only Option",
onclick: HelloWorld
});
And set them for a chart:
exporting: {
buttons: {
contextButton: {
menuItems: buttons // or buttons.slice(0,6)
}
}
},
Problem
I have a page with several charts, and I need to be able to add specific options to the exporting context menu for each chart. This is the code I am using: ``` myChart.options.exporting.buttons.contextButton.menuItems.push({ text: "Custom Option", onclick: someFunction }); ``` Unfortunately, this adds the option to every chart, not just the chart myChart references. I'd like to be able to add an option and have it appear on only one chart. Here is a fiddle which demonstrates: http://jsfiddle.net/4uP5y/2/ Thanks!