.force("links", d3.forceLink(linksData).id(function(datum){ //add this
return datum.name
return datum.name //add this
}).distance(160))
}).distance(160)) //add this
```
```
- The `d3.forceLink` function takes the array of links. It then uses the `source` and `target` attributes of each link data object to connect the nodes via their `.name` properties (as specified in the return value)
- The `d3.forceLink` function takes the array of links. It then uses the `source` and `target` attributes of each link data object to connect the nodes via their `.name` properties (as specified in the return value)
@ -175,6 +192,8 @@ d3.forceSimulation()
## Specify how the simulation affects the visual elements
## Specify how the simulation affects the visual elements
At this point, our visualization still looks the same as before. Let's have our various forces affect the circles/lines that we created
- The simulation runs "ticks" which run very quickly
- The simulation runs "ticks" which run very quickly
- Each time a new "tick" occurs, you can updated the visual elements
- Each time a new "tick" occurs, you can updated the visual elements
You'll notice that the cx/cy values for the circles and the x1/x2/y1/y2 values for the lines change rapidly initially before finally stopping. This is because D3 is trying is running a simulation. The various forces are trying to reach a state of equilibrium with each other. You'll even notice when you first load the page that the circles and lines move a bit as well. This is due to the same reason.