By adding transitions, we can more easily follow the elements as they are entered, updated and exited. Separate transitions are defined for each of the three states.
Note that no transition is applied to the merged enter + update selection; this is because it would supersede the transition already scheduled on entering and updating elements. It’s possible to schedule concurrent elements by using transition.transition or by setting transition.id
, but it’s simpler here to only transition the x-position on update; for entering elements, the x-position is assigned statically.
Want to read more? Try these tutorials:
See the D3 wiki for even more resources.
Previous: Key Functions
forked from mbostock‘s block: General Update Pattern, III