Creating a simulation

Now, we'll generate a simulation by adding the following to the bottom of app.js:

d3.forceSimulation()

Note that this simply creates a simulation; it doesn't specify how the simulation should run. Let's tell it which data to act on by modifying the previous line of code, as follows:

d3.forceSimulation()
    .nodes(nodesData) // add this line

Get D3.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.