How to make highcharts default to 0 for missing data

Solution 1:

One way is by pre-processing the data, replacing null with 0:

var withNulls = [null, 12, 23, 45, 3.44, null, 0];
var noNulls = withNulls.map(function (item) {
    return (item === null) ? 0 : item;
});

Example saved on jsfiddle: http://jsfiddle.net/7mhMP/

Solution 2:

I've thorougly searched the API reference of HighCharts, but they don't offer that option. What they do offer is the option to disable the connection of points when null data is in between (only line and area charts):

var chart = new Highcharts.Chart({
    plotOptions: {
        line: {
            connectNulls: false
        }
    }
});

This is the default setting according to the API, so I'm not sure why your data does connect with null values in between. Maybe they have changed the defaults lately?

Example of HighChart with missing data

I feel this is a good representation of your data, because defaulting null to 0 seems misleading.

Solution 3:

You hava to fill the missed data as 0. Because highchart don't konw xAxis interval.

If you have a time series at a 1 minute interval, you should set every missing minute data to 0; If you have a time series at a 1 day interval, you should set every missing day data to 0.