D3 sample code is a struggle

D3 sample code is a struggle
0.0 0


I’m trying to get the sample code for a force directed graph working.

The difference is I have added the JSON directly to the code. That seems to be enough to break it.

I think the problem starts here:

 var link = svg.append("g")
    .attr("class", "links")
    .attr("stroke-width", function(d) { return Math.sqrt(d.value); });


The example shows:

var svg = d3.select("svg")

But you have:

const svg = document.querySelector("svg")