Skip to main content
100%

d3 datum()

✓ Published1🌍 Public
Ssgzzhinde
Last edited Jan 11, 2021
Created on Jan 11, 2021
Forked from Hello d3 selector

This example demonstrates how the `datum()` method binds a single piece of data to multiple DOM selections at once. The page contains four empty `<h3>` elements, and the script selects them all with `d3.selectAll('h3')`, then calls `datum('i am a little bird')` to attach the string to each element. Using the `.text()` method with an accessor function, it renders both the bound value and the element’s index, showing that the same data is shared across all selected nodes. The code uses D3 v5 and plain JavaScript in a simple HTML file.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.

MIT Licensed

Similar vizzes