Skip to main content
100%

11. D3 Drawing Divs Spaced

✓ Published1🌍 Public
Aamakanju@nyit.edu
Last edited Feb 11, 2026
Created on Feb 9, 2026

Five teal bars appear in a row across the page, each representing a value from the static dataset `[5, 10, 15, 20, 25]`. Using D3 v4.5, the code selects the body, binds the data, and appends a `div` for each number. The bars are spaced with inline-block styling and margin, while each height is set dynamically via `.style('height', ...)` as the data value multiplied by five pixels. This example demonstrates the basic data-join pattern and the use of D3’s `.selectAll`, `.data`, and `.enter` methods to generate DOM elements.

AI-generated description
MIT Licensed

Similar vizzes