简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM