chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
const nodes = svg
.selectAll("text")
.data(graph.nodes)
.join("text")
.attr("font-size", (v) => v.INCOME_PC * 0.001)
.attr("fill", "royalblue")
.text((v) => v.STATE_ABBR);
const links = svg
.append("g")
.attr("stroke", "none")
.attr("stroke-width", 1)
.selectAll("line")
.data(graph.links)
.join("line");
setupDrag(svg, nodes, simulation);
function update() {
nodes.attr("x", (v) => v.x).attr("y", (v) => v.y);
links
.attr("x1", (e) => e.source.x)
.attr("y1", (e) => e.source.y)
.attr("x2", (e) => e.target.x)
.attr("y2", (e) => e.target.y);
}
simulation.on("tick", update);
update();
return svg.node();
}