stee1rat
stee1rat

Reputation: 730

Highcharts selection, yaxis is undefined

I would like to get the min and max values of yAxis for the selection on the Highcharts graph. I can get the xAxis values:

$(function () {
    var $report = $('#report');

    // create the chart
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            events: {
                selection: function(event) {                    
                $report.html('min: ' + event.xAxis[0].min +
                             ', max: ' + event.xAxis[0].max);
                return false;                        
                }
            },
            zoomType: 'x'
        },
        xAxis: {
        },

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

http://jsfiddle.net/yx1z0qwg/

But when I change xAxis to yAxis in the above mentioned example - nothing happens. This is because yAxis part of the event array is undefined for some reason. But the documentation says that there should be an yAxis array in the event: http://api.highcharts.com/highcharts#chart.events.selection.

How can I can get the yAxis min and max values for the selection?

Upvotes: 0

Views: 739

Answers (1)

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

This issue is caused by setting zoom only for x (zoomType:'x'). Switch that to y or xy (as you need) then will work.

Upvotes: 2

Related Questions