Adding a right click context menu to highcharts
Posted by Chris | Posted in Javascript | Posted on 01-08-2012
Tags: highcharts
1
I’m a big fan of the highcharts charting library. It’s completely client side, looks great, and performs great. However one currently missing feature is the ability to catch the right click event on a chart to add a context menu. To provide this functionality I’ve forked the v2.2.1 version of highcharts which you can find here or use this direct link to highchart.src.js.
To implement this I used the code from Joe Kuan as a starting point which provided the context menu event for a chart and made changes to add the context menu event to a chart legend, provide more accurate mouse coordinates across browsers and to also show the right click context menu for point charts.
The context menu events can be setup as follows:
var newChart = new Highcharts.Chart({
plotOptions: {
series: {
events: {
legendContextMenu: function(e) {
// use e.mousePageX and e.mousePageY for mouse coordinates
}
},
point: {
events: {
contextmenu: function(point) {
// use this.mousePageX and this.mousePageY for mouse coordinates
}
}
}
}
}
});





[...] recently pushed a change to github to add right click context menu functionality to highcharts. However my change applied to [...]