highchart connect nulls only when two values are close (aka by distance)

137 views Asked by At

I have a line chart with daily data and I want the nulls to be connected only in the case that the nulls span a day or two, not if there's a gap of weeks. know highchart has a function connectnull but I'm having trouble programming it to work only for short gaps in data. Does anyone know how to go about this?

1

There are 1 answers

0
ppotaczek On

There is a single property for such functionality. You can for example filter your data and remove null points which are located in small intervals. For example:

const filteredData = data.filter((dataEl, index) => {
    const prevPoint = data[index - 1];
    const nextPoint = data[index + 1];

    if (!dataEl[1] && prevPoint && nextPoint) {
        return nextPoint[0] - prevPoint[0] > 2;
    }
    return true;
});

Live demo: http://jsfiddle.net/BlackLabel/akrtuLh1/

API Reference: https://api.highcharts.com/highcharts/series.line.data