Adding lines to the SVG

Add the following to the bottom of app.js:

var links = d3.select("#links")
    .selectAll("line")
    .data(linksData)
    .enter()
    .append("line");

This will create a line for each element in our linksData array. Our Developer tools should look as follows:

Get D3.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.