Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two different thresholds in HighCharts 3.0

With HighCharts 3.0, it is now possible to indicate to colors above and below one threshold. Like this example :

http://jsfiddle.net/highcharts/YWVHx/

Following code :

$(function () {
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=range.json&callback=?', function(data) {

        $('#container').highcharts({

            chart: {
                type: 'arearange'
            },

            title: {
                text: 'Temperature variation by day'
            },

            xAxis: {
                type: 'datetime'
            },

            yAxis: {
                title: {
                    text: null
                }
            },

            tooltip: {
                crosshairs: true,
                shared: true,
                valueSuffix: '°C'
            },

            legend: {
                enabled: false
            },

            series: [{
                name: 'Temperatures',
                data: data,
                color: '#FF0000',
                negativeColor: '#0088FF'
            }]

        });
    });

});

Is it possible to have another threshold with a third color, like this for example :

Chart with a double threshold

Thanks in advance for your help.

like image 906
Thordax Avatar asked Jun 04 '13 20:06

Thordax


1 Answers

It actually is possible if you don't mind plotting the data twice.

    $('#container').highcharts({

        chart: {
            type: 'arearange'
        },

        title: {
            text: 'Temperature variation by day'
        },

        xAxis: {
            type: 'datetime'
        },

        yAxis: {
            title: {
                text: null
            }
        },

        tooltip: {
            crosshairs: true,
            shared: true,
            valueSuffix: '°C'
        },

        legend: {
            enabled: false
        },

        series: [{
            name: 'Temperatures',
            threshold : 0,
            data: data,
            color: 'orange',
            negativeColor: 'blue'
        },
        {
            name: 'Temperatures',
            threshold : 10,
            data: data,
            color: 'red',
            negativeColor: 'transparent'
        }]
    });
});

http://jsfiddle.net/YWVHx/97/

like image 164
Ronald van Wijnen Avatar answered Oct 03 '22 14:10

Ronald van Wijnen