I hope to show an empty day to 0 in highcharts

I use a line / area chart to display time and time data. see example: http://jsfiddle.net/YFERb/

$(function () { var chart = new Highcharts.Chart({ chart: { renderTo: 'container' }, xAxis: { type: 'datetime' }, series: [{ data: [ [Date.UTC(2010, 0, 1), 29.9], [Date.UTC(2010, 0, 3), 106.4], [Date.UTC(2010, 0, 5), 75], [Date.UTC(2010, 0, 6), 129.2], [Date.UTC(2010, 0, 10), 176.0] ] }] }); }); 

But I want to fill an empty day to 0. see example: http://jsfiddle.net/RSPNU/

therefore 0. is filled below the day. 2010.0.2, 2010.0.4, 2010.0.7, 2010.0.8, 2010.0.9

Insert 0 on an empty day. But it is very hard.

So, I want to display as the 2nd example, except for inserting 0 or null data.

If you have another way, answer that. thanks.

+4
source share
2 answers

To avoid dots, you can set to null .
When you do this, your graph will have a gap between zero points, so you need to set connectNulls to true .

 series: [{ data: [ [Date.UTC(2010, 0, 1), 29.9], [Date.UTC(2010, 0, 2), null], [Date.UTC(2010, 0, 3), 106.4], [Date.UTC(2010, 0, 4), null], [Date.UTC(2010, 0, 5), 75], [Date.UTC(2010, 0, 6), 129.2], [Date.UTC(2010, 0, 7), null], [Date.UTC(2010, 0, 8), null], [Date.UTC(2010, 0, 9), null], [Date.UTC(2010, 0, 10), 176.0] ] }], plotOptions: { series: { connectNulls: true } } 

demonstration

+1
source

In general, how should Highcharts know that you want to set 0 every day, not every hour, but maybe every second? If you know how your data is trimmed, you can set pointInterval and pointStart for the series. Then you can update each of the points, which should have a different value, see Example: http://jsfiddle.net/YFERb/3/

+1
source

All Articles