I can't seem to get the category from a Highchart returned on a click event on the chart itself. In other words, this works fine:
plotOptions: {
series: {
events: {
click: function(ev) {
console.log(ev.point.category); // outputs category
}
}
}
}
However, what I'd like is to be able to get the category when a user clicks anywhere on the chart, not just on the point. It would look something like this
chart: {
events: {
click: function(ev) {
console.log(ev.xAxis[0].category); // undefined because doesn't exist - sure would be nice, tho
}
}
}
I've combed through both the event and the highcharts objects here, but without being able to find how to identify which category is associated with the x-value being returned.
You can get position x value and map to categories. Example:
click:function(e){
alert('x: ' + categories[Math.floor(e.xAxis[0].value)]);
}
http://jsfiddle.net/pev5zos8/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With