score:16

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

More Query from same tag