This example shows the very basics of the D3 data binding system, which creates selections via data joins.
A set of circle
elements are initialized with data
, which creates the three selections:
enter
selection: elements that did not previously exist.update
selection: elements that currently exist.exit
selection: elements that exist, but have no longer have data.In this code, for each element in the enter
group, we append a new circle
element. We then calculate its properties from the data that has been joined with it.
For a full explanation and demo, see the General Update Pattern article.
This code block is preceded by initialization code that defines parent
, svg
, margin
, width
, & height
.