In the answer to this question, mbostock notes that "if a node is fixed, it can only be moved by dragging and not by the simulation."
What if I'd like to position the nodes programmatically, however, perhaps by setting the d.x and d.y values? My attempts thus far have failed. I have tried the obvious setting of d.x and d.y, but these values are ignored for fixed nodes. I've also attempted to temporarily "un-fix", redraw, then "re-fix" the nodes, but this also doesn't work -- the nodes are magically reset to their original positions on the next tick.
Here's a running example of this latter approach.
Here's the key bit of that code, executed on click:
function explicitlyPosition() {
node.each(function(d) {
d.x = 0;
d.y = 0;
d.fixed = false;
});
tick();
node.each(function(d) {
d.fixed = true;
});
force.resume();
}
Is there a way to do this using the approach I've tried or one similar? Or I could use a totally different graph layout in D3, but I would ideally like large portions of my graph to be laid out in a force-directed manner.
Thanks!