Highcharts Demo

author(s): Torstein Hønsi

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 300px"></div>

JavaScript

$(function () {
    $('#container').highcharts({
        title: {
            text: 'The line is connected from April to Juni, despite the null value in May'
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },

        plotOptions: {
            series: {
                connectNulls: true
            }
        },
        tooltip: {
            formatter: function(){
                if(this.point.isNull == undefined)
                    return this.series.name+"<br>"+"<b>value:</b>"+this.y;
                return this.series.name;
            }
        },
        series: [{
            data: [null, 71.5, 106.4, 129.2, null, 176.0, 135.6, null, 216.4, 194.1, 95.6, 54.4]
        }]

    }, function(chart){
        var series = chart.series[0];
        var data = series.data;
        $.each(data,function(i){
            var point = data[i];
            var prevPoint = data[i-1] != undefined ? data[i-1].y : 0;
            var nextPoint = data[i+1] != undefined ? data[i+1].y : 0;
            if(point.y == null){
                series.addPoint({x:point.x,y:(prevPoint+nextPoint)/2, isNull:true});
            }
        });
    });
});