chart = {
console.log(`yeet ${button.value}`);
window.addEventListener("mouseover", function (e) {console.log(e);});
const edges = data.edges.map(d => Object.create(d));
const nodes = data.nodes.map(d => Object.create(d));
const simulation = Object.entries(forces)
.reduce(
(simulation, [name, force]) => simulation.force(name, force),
d3.forceSimulation(nodes)
).force("link", d3.forceLink(edges).id(d => d.id).strength(1));
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const edge = svg.append("g")
.attr("stroke", "#000")
.selectAll("line")
.data(edges)
.join("line")
.attr("stroke-width", d => .4);
const node = svg.append("g")
.attr("stroke", "#000")
.attr("stroke-width", .5)
.selectAll("g")
.data(nodes)
.join("g")
.call(drag(simulation));
node.append("title")
.text(d => d.id);
let rect = node.append("rect")
.attr("width", 120)
.attr("height", 48)
.attr("rx", 4)
.attr("ry", 4)
.attr("fill", "teal");
let text = node
.append("text")
.attr("width", 120)
.text(d => d.id)
.attr("font-size", 12)
.attr("stroke", "none")
.attr("fill", "white");
simulation.on("tick", () => {
edge
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y);
node
.attr("x", d => d.x)
.attr("y", d => d.y);
rect
.attr("x", d => d.x)
.attr("y", d => d.y - 20);
text
.attr("opacity", d => Math.max(mouse.x, d.x))
.attr("x", d => d.x)
.attr("y", d => d.y);
});
invalidation.then(() => simulation.stop());
return svg.node();
}