🌍 Public
Viewing a saved revision (read-only)
4fb3f035221747e9ad8be6525d5b3ff3
d3 update() exit()
This example demonstrates how D3's update and exit states work when binding data to existing DOM elements. It shows four paragraph elements for dog, cat, pig, and rat, which are then bound to a two-item dataset using `d3.select('body').selectAll('p')` and `.data(dataset)`. The update state calls `.text()` to display values, while the exit state uses `.exit()` to label elements that no longer have corresponding data, showing their index positions. The code explicitly avoids calling `.remove()` on the exiting elements, leaving them visible for inspection in the browser.
AI-generated descriptionA bare minimum HTML page demonstrating use of CSS and JavaScript.
See also React Starter.