JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgithub.com/highslide-software/highcharts.com/master/js/adapters/standalone-framework.src.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script src="http://code.highcharts.com/modules/drilldown.js"></script>
<p>The Custom menu option 'Tokyo Only Option' should only appear in the Tokyo chart, but it appears in both.</p>
<div id="containerTokyo" style="min-width: 300px; height: 300px; margin: 1em"></div>
<div id="containerNewYork" style="min-width: 300px; height: 300px; margin: 1em"></div>
JavaScript
var chartTokyo = new Highcharts.Chart({
chart: {
renderTo: 'containerTokyo'
},
title: {
text: 'Tokyo Average Temperature',
x: -20 //center
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [ {
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}]
});
var chartNewYork = new Highcharts.Chart({
chart: {
renderTo: 'containerNewYork'
},
title: {
text: 'New York Average Temperature',
x: -20 //center
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [ {
name: 'New York',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}]
});
HelloWorld = function (){
alert("Hello World");
}
// This option should only appear in the Tokyo chart, but ti appears in both
chartTokyo.options.exporting.buttons.contextButton.menuItems.push({
text: "Tokyo Only Option",
onclick: HelloWorld
});