2012-07-26 98 views
3

我有一種情況需要預測時間序列中的趨勢,並且必須顯示置信區間。有沒有辦法將Highcharts中的兩組y值作爲鏈接來繪製,並遮蔽兩者之間的區域?事情是這樣的:Highcharts - 突出顯示兩個y值之間的區域

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

我有五個時間序列:即綁定的窄置信區間的預測,兩個時間序列,而且必將更廣泛的置信區間兩個時間序列。

回答

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)' 
     }] 
    }); 
}); 
+0

所以我的想法是,我把信心區間放在彼此的頂部,然後畫預測線一切的頂部? – 2012-07-26 19:52:32

+0

@Andrew C,這是正確的。 – kingjeffrey 2012-07-26 19:57:09