score:2

Accepted answer

it can be done using api after chart is rendered:

var chart = $('#container').highcharts();
var extremes = chart.yaxis[0].getextremes();
var maxy = extremes.max;
var miny = extremes.min;

chart.yaxis[0].addplotband({
            color: 'green',
            from: 150,
            to: maxy
});
chart.yaxis[0].addplotband({
            color: 'red',
            from: miny,
            to: '150'
});

function getextremes() returns current extremes for the axis (datamax, datamin, max and min axis value). and those values are used to set proper bands. note: additional check should be done if hardcoded value (150) is between miny and maxy.

see updated example at jsfiddle.


Related Query