Skip to content Skip to sidebar Skip to footer

Add Event To X-axis Labels Of Bar Highchart

I am trying to retrieve the text of a label on the char x-axis by clicking on it. I am using bar chart and the code is the following: var chart = new Highcharts.Chart({ chart:

Solution 1:

Instead of:

$('body').on('click', 'g.highcharts-axis-labels.highcharts-xaxis-labels text', function () {
    console.log($(this).text());
});

Use this:

$('.highcharts-xaxis-labels text').on('click', function () {
    console.log($(this).text());
});

You should not connect classes highcharts-axis-labels and highcharts-xaxis-labels with a dot. And also the class highcharts-xaxis-labels is enough to add the event on. Here's the fiddle: http://jsfiddle.net/8sxLr5j8/

Solution 2:

You can use extension which allows do it.

Post a Comment for "Add Event To X-axis Labels Of Bar Highchart"