Search code examples
javascripthighchartsjquery-eventsscatter-plot

Highcharts scatter plot: alert coordinates on click event


I am using Highcharts' scatter plot and I'm trying to alert the coordinates (x,y) when someone clicks on a scatter plot's point.

You can see my options so far here: http://jsfiddle.net/athanott/ARf9M/

I only added

cursor: 'pointer',
            events: {
                click: function(event) {
                    alert('x: ' + event.xAxis[0].value);
                }
            }},

under plotOptions. If I delete the event.xAxis[0].value part in the alert command, the rest is printed normally, but it doesn't work as it is.

Any suggestions?


Solution

  • You can use event.chartX and event.chartY like so: JSFiddle