I have the following code :
var simulation = d3v5.forceSimulation()
.force('link', d3v5.forceLink().id(function (d) { return d.id; }))
.force('charge', d3v5.forceManyBody())
.force('center', d3v5.forceCenter(width / 2, height / 2))
Here is an example codePen (see line 57): https://codepen.io/anon/pen/PdOqZK?editors=1010
The last line sets the force center. When I drag nodes around and have this center being set, the nodes seem to go out from the center. But when I have the following :
var simulation = d3v5.forceSimulation()
.force('link', d3v5.forceLink().id(function (d) { return d.id; }))
.force('charge', d3v5.forceManyBody())
.force('x', d3v5.forceX(width / 2))
.force('y', d3v5.forceY(height / 2))
Here is an example codePen (see line 57): https://codepen.io/anon/pen/gdXprR?editors=1010
It works as expected. Would be great if someone could explain what's happening.