2012-03-28 25 views
11

API未顯示如何使用connectNulls屬性的適當示例。我有一些嘗試,但沒有運氣。以下是我有:在Highstock圖表中連接NULL點

嘗試1:

plotOptions : 
{ 
    line: { connectNulls : true} 
}, 

這導致:TypeError: Cannot read property 'x' of undefined

嘗試2:

plotOptions : 
{ 
    series: 
    { 
     gapSize: null, 
     line: { connectNulls : true} 
    } 
}, 

這不會給我任何錯誤,所以我認爲這是最接近正確的方式,但沒有任何變化:重點s從null兩側任何一點都沒有連接。

任何人都可以共享一個代碼,顯示正確的做法嗎?

回答

18

highcharts API有兩個connectNulls屬性的示例:一個用於true,另一個用於false

http://api.highcharts.com/highcharts#series.connectNulls

true例如:http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-connectnulls-true/

true示例的片斷:

plotOptions: { 
     series: { 
      connectNulls: true 
     } 
    }, 

false例如:http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-connectnulls-false/

false電子一個片段xample:

plotOptions: { 
    series: { 
     // connectNulls: false // by default 
    } 
}, 

false默認值是一個深思熟慮的選擇,因爲當你連接值時,沒有數據,其結果可能導致對圖表的觀衆的部分錯誤的假設。

UPDATE

這裏有一個Highstock例如:

$(function() { 

     window.chart = new Highcharts.StockChart({ 
      chart : { 
       renderTo : 'container' 
      }, 

      rangeSelector : { 
       selected : 1 
      }, 

      title : { 
       text : 'AAPL Stock Price' 
      }, 

      series : [{ 
       name : 'AAPL', 
      connectNulls: true, 
       data : [ 
    [1112832000000,43.56], 
[1112918400000,43.74], 
[1113177600000,41.92], 
[1113264000000,null], 
[1113350400000,null], 
[1113436800000,37.26], 
[1113523200000,35.35], 
[1113782400000,35.62], 
[1113868800000,37.09], 
[1113955200000,35.51], 
[1114041600000,37.18], 
[1114128000000,35.50], 
[1114387200000,36.98], 
[1114473600000,36.19], 
[1114560000000,35.95], 
[1114646400000,35.54], 
     [1114732800000,36.06]   
     ], 
       tooltip: { 
        valueDecimals: 2 
       } 
      }] 
     }); 

}); 
+0

奇怪,我提供沒有例子的鏈接,但你一樣。看起來像highstock和highchart文檔是不同的。 – unexplored 2012-04-05 13:10:25

+0

@unexplored - 添加了HighSTOCK示例。 – mg1075 2012-04-05 14:27:27

+0

所有鏈接現已停止。 – MightyPork 2014-08-06 18:02:00