score:1

Accepted answer

NaN is not a correct point format, just like String or Boolean. If value is not a number then it's treated as null-point. I think you want to use opposite options: connectNulls to false and just remove null points, with given indexes, demo: http://jsfiddle.net/BlackLabel/fquznbeq/4/

You can automate this process: http://jsfiddle.net/BlackLabel/fquznbeq/8/

function toHCFormat(data) {
  var formatted = [];

  data.forEach(function (point, i) {
    if (point === null) {
      // do nothing
    } else if (isNaN(point)) {
      formatted.push([i, null]);
    } else {
      formatted.push([i, point]);
    }
  });

  return formatted;
}

Use:

data: toHCFormat([
  20,
  60,
  null,
  11,
  null,
  160,
  120,
  130,
  NaN,
  NaN,
  80,
  40
]),

Related Query

More Query from same tag