`d3.forceX()` pulls nodes toward a horizontal position in a D3 force simulation. For example, `forceX(0)` draws nodes toward x = 0 while leaving them loosely spread along the y-axis. Pair it with `forceY(0)` and both forces draw nodes toward (0, 0). section 12.4.1
Use `.strength()` to adjust the pull. Its default is 1; reducing the x-force strength to 0.01 while retaining `forceY(0)` makes horizontal attraction weaker than vertical attraction. A position can also come from a scale, giving different groups distinct targets. section 12.4.1
Position values in a beeswarm
Add `.force("x", forceX(d => xScale(d.value)))` to position each node horizontally by its value. Combine it with `forceY(0)` and `forceCollide().radius(7)` to form a beeswarm plot whose circles do not overlap. section 12.4.1
forceSimulation()
.force("x", forceX(d => xScale(d.value)) )
.force("y", forceY(0) )
.force("collide", forceCollide().radius(7) )
.nodes(sampleNodes)
.on("tick", updateNetwork);
See how the x-force, y-force, and collision force are registered together in a working simulation. section 12.4.1
