D3 force layout fix root node at the center

force.on("tick", function() {
    nodes[0].x = w / 2;
    nodes[0].y = h / 2;

That should do it.

Leave a Comment