Accepted answer

Consider using the built-in line generator d3.svg.line(). By providing an appropriate accessor function to line.defined() you can specify where the line is defined and how to handle your null values:

The defined accessor can be used to define where the line is defined and undefined, which is typically useful in conjunction with missing data; the generated path data will automatically be broken into multiple distinct subpaths, skipping undefined data.

Note, however, that the line generator by default assumes your data is provided as a two-dimensional array, but you could easily map your input array accordingly or provide appropriate accessor functions to line.x() and line.y().

Related Query

More Query from same tag