Accepted answer

it seems you are missing the <style> section from that example. the fill: none is what tells the line not to close from the last point to the first one:

.line {
  fill: none;
  stroke: steelblue;
  stroke-width: 1.5px;

you are telling it to use this class:

.attr("class", "line")

but if "line" doesn't exist in referenced css or inline styles you will get the default fill behavior.

see also: d3.js tree with odd number of vertices, edges not shown

Related Query