highcharts. How to determine the coordinates of the point where the CLICK was made?

How to determine the coordinates of the point where the CLICK was made. If the CLICK was made exactly on the line of the graphic (not on the point of the graphic).

chart: { 
 events: {
  click: function(event) {}
 }
},

Not work

Upvotes: 0

Views: 2030

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

I think you should use plotOptions.series.events.click, not chart.events.click. Then simply set tooltip.snap = 1 to get clicks only when cursor is really close to the line/point. To get coordinates use event.chartX and event.chartY:

    tooltip: {
        snap: 1  
    },
    plotOptions: {
        series: {
            events: {
                click: function (e) {
                    console.log(e.chartX, e.chartY);
                }
            },
        }
    },

Demo: http://jsfiddle.net/dxj7wemh/

Upvotes: 1

Related Questions