Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get chart object inside a point event function in Highcharts

How have I to modify the following example to get the point value in the first series even when clicking on a point in the second series? It suffices to me to get the chart object but I don't know how to do (inside point mouseOut function this refers to point object and not to chart object).

$(function () {
    $('#container').highcharts({
        plotOptions: {
            series: {
                cursor: 'pointer',
                point: {
                    events: {
                        click: function () {
                            // here I want the y value of the point in the
                            // first series even in this function 
                            // is invoked for the point in the second series
                            alert('value: ' + this.y);
                        }
                    }
                }
            }
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0]
            },{
            data: [135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
        }]
    });
});

JSfiddle page

like image 377
tic Avatar asked Sep 26 '22 18:09

tic


1 Answers

According to the docs:

The this keyword refers to the Point object.

Point in turn has series property that holds chart:

series: {
    cursor: 'pointer',
    point: {
        events: {
            click: function() {
                var chart = this.series.chart;
            }
        }
    }
}
like image 93
miensol Avatar answered Oct 03 '22 19:10

miensol