HighCharts 3.0中有两个不同的阈值

Tho*_*dax 6 highcharts threshold

使用HighCharts 3.0,现在可以指示高于和低于一个阈值的颜色.像这个例子:

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

以下代码:

$(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'
            }]

        });
    });

});
Run Code Online (Sandbox Code Playgroud)

是否可以使用第三种颜色的另一个阈值,例如:

具有双重阈值的图表

在此先感谢您的帮助.

小智 9

如果你不介意两次绘制数据,实际上是可能的.

    $('#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'
        }]
    });
});
Run Code Online (Sandbox Code Playgroud)

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


Hal*_*and 7

在Highcharts 4.1.0(2015年2月)中添加了一个没有"hacks"解决此问题的功能,称为区域(API).使用区域可以像这样解决给定的问题:

plotOptions: {
    series: {
        zones: [{
            value: 0, // Values up to 0 (not including) ...
            color: 'blue' // ... have the color blue
        },{
            value: 10, // Values up to 10 (not including) ...
            color: 'orange' // ... have the color orange
        },{
            color: 'red' // Values from 10 (including) and up have the color red
        }]
    }
}
Run Code Online (Sandbox Code Playgroud)

请参阅JSFiddle演示它的外观.