2017-10-19 114 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/

相关问题