Vivek Aditya
Vivek Aditya

Reputation: 1173

Unable to trigger a click event on series data | Highchart

I am trying to fire a click event in a series of data ( I am using Highcharts ) . My approach is as follows. I have the click event added in the plotOptions rather than point as it is done here which is working fine.

The issue (I think) is that firePointEvent is not working but clicking manually does fire the event.

var chart = $("#container").highcharts();
chart.series[0].data[0].firePointEvent('click');

Is there something I am missing or am I wrong somewhere ?

Upvotes: 2

Views: 3339

Answers (2)

Paweł Fus
Paweł Fus

Reputation: 45079

The problem is that you are setting chart.plotOptions.series.events.click, but the original demo is using chart.plotOptions.series.point.events.click.

In case you want to fire an event programatically for a series, use:

Highcharts.fireEvent(chart.series[index], 'click', event);

Demo: http://jsfiddle.net/qxjzzymb/

Upvotes: 1

Asad Sarwar
Asad Sarwar

Reputation: 583

In this case events can be referred:

chart.options.plotOptions.series.events.click(chart.series[series index]);

and get series inside chart like:

click: function(event) {
console.log(event);
alert(event.name + ' clicked\t');

jsfiddle

Upvotes: 2

Related Questions