2017-10-19 70 views
0

我想指出圖中存在空值。如何指示空值,但不要在Highcharts Line graph中連接它?

我想用0替換null,但是,它會連接其餘的實際數據,並繪製不正確的圖形。是否有可能不將零值與其餘數據點連接?

另外,是否有可能使用圖上顯示的空白區域來指示空值?

jsfiddle

var categoryText= ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; 

Highcharts.stockChart('container',{ 

    chart: { 
     defaultSeriesType: 'spline', 
     renderTo: 'container' 
    }, 

    xAxis: { 
    labels: { 
       formatter: function() { 
        return categoryText[this.value]; 
       } 
      } 

    }, 
    plotOptions: { 
     series: { 
      marker: { 
       enabled: true 
      } 
     } 
    }, 
    series: [{ 
     data: [29.9, null, 106.4, 129.2, 144.0, 176.0, null, 148.5, 216.4, 194.1, 95.6, 54.4], 
    }] 

}); 

enter image description here

+0

所以,你要顯示與橙色條空值? –

+0

@NanduKalidindi不是酒吧,我在想情節帶。 – devN

回答

1

如果你在上面聲明的數據,那麼你可以試試這個只包括了null陰謀樂隊。我試着調整每個tick的偏移量到月中,但似乎有點不準確。請根據您的喜好調整。看看小提琴。

plotBands: data.map(function(item, index) { 
      return { color: 'orange', from: index-0.5, to: index+0.5, data: item } 
       }).filter(function(item) { return item.data === null}) 
      }, 

http://jsfiddle.net/95dLon47/3/