Highcharts - 突出显示两个y值之间的区域

时间:2012-07-26 18:10:58

标签: javascript graph highcharts area confidence-interval

我有一种情况需要预测时间序列中的趋势,我必须显示置信区间。有没有办法在Highcharts中绘制两组y值作为链接,并遮蔽两者之间的区域?像这样:

http://www.psychosomaticmedicine.org/content/74/4/377/F2.large.jpg

我有五个时间序列:预测,限制较窄置信区间的两个时间序列,以及另外两个限制较宽置信区间的时间序列。

2 个答案:

答案 0 :(得分:1)

Highcharts本身不支持范围图表(从2.2.5版开始),但有一种解决方法。您可以将两个区域系列叠加在一起,最前面的系列具有与图表背景相匹配的背景颜色。

以下是示例javascript(导致this chart):

var chart;
$(document).ready(function() {
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container', 
            defaultSeriesType: 'area'
        },
        title: {
            text: 'Range chart emulation'
        },
        xAxis: {
        },
        yAxis: {    
        },
        plotOptions: {
            area: {
                pointStart: 1940,
                marker: {
                    enabled: false,
                    symbol: 'circle',
                    radius: 2,
                    states: {
                        hover: {
                            enabled: true
                        }
                    }
                },
                lineWidth: 0,
                stacking: 'normal'
            }
        },
        series: [{
            // this series defines the height of the range
            name: 'Range',
            data: [1,2,3,5,7,8,9,6,4,7,5,3,4,7,6,5,6,7,5,4,2]
        }, {
            // this series defines the bottom values
            name: 'Dummy',
            data: [0,1,2,3,3.5,7,8.5,5,2.5,5.5,3,2,3,5.5,4,3,4,5.5,4,3.5,1.5],
            enableMouseTracking: false,
            showInLegend: false,
            fillColor: 'rgba(255, 255, 255, 0)'
        }]
    });
});

答案 1 :(得分:1)

新的Beta有这个功能:

see jsFiddle

您可以阅读有关即将推出的功能的更多信息in this post.