This post describes how to build a very basic circular packing with d3.js. In this example, 8 nodes are represented by 8 circles of same size. You can see many other examples in the circular packing section of the gallery.
data
is pretty simple, each node just have a name.enter()
and append()
approach. All circles are initialized with the same position: the center of the svg
area.d3.forceSimulation()
allows to define the forces we want to apply to circlesforceCenter
), are slightly attracted one each other (forceManyBody
), and overlapping is avoided (forceCollide
).tick
), node position is updated