vis = {
await visibility();
const links = data.links.map(d => Object.create(d));
const nodes = data.nodes.map(d => Object.create(d));
const simulation = d3.forceSimulation(nodes)
.force("link", d3.forceLink(links).id(d => d.id))
.force("charge", d3.forceManyBody().strength(-30))
.force('collide', d3.forceCollide((180/data.nodes.length)+10))
.force("x", d3.forceX())
.force("y", d3.forceY());
const svg = d3.select(DOM.svg(1000, 880));
svg.attr("viewBox", [-width / 2, -height / 2, width, height]);
const g = svg.append("g").attr("id", "circles")
const node = g.selectAll("circle")
.data(nodes)
.enter()
.append("circle")
.attr("r", r)
.attr("fill", color)
.call(drag(simulation));
const link = svg.append("g")
.attr("stroke-opacity", 0.6)
.selectAll("line")
.data(links)
.enter()
.append("line")
.attr("stroke", lineColor)
.attr("stroke-width", d => Math.sqrt(5));
svg.append("g").attr("id", "annotation");
svg.append("g").attr("id", "testdetail");
simulation.on("tick", () => {
link
.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("cx", d => d.x)
.attr("cy", d => d.y);
});
invalidation.then(() => simulation.stop());
return svg.node();
}