chart = {
const svg = d3.select(DOM.svg(width, height));
let nodes = svg.selectAll("g").data(dynamicData.nodes)
let edges = svg.selectAll("line").data(dynamicData.links)
console.log(dynamicData.links)
var enterEdges = edges.enter().append("line").lower()
.attr("stroke", "#222")
.attr("stroke-opacity", 0.2)
.attr("stroke-width", 1)
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y)
var enterNodes = nodes.enter().append("g")
.append('circle')
.attr("stroke", "#FFF")
.attr("stroke-width", 0.2)
.attr("class","node")
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("r", d => d.r || 5)
.attr("fill", d => d.color)
.call(drag());
nodes = nodes.merge(enterNodes);
edges = edges.merge(enterEdges);
function ticked() {
edges
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y);
nodes
.attr("cx", d => d.x)
.attr("cy", d => d.y);
};
simulation
.on("tick", ticked)
return svg.node();
}