Skip to main content
Public

Share visualization

Loading preview…

11. D3 Drawing Divs Spaced

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

11. D3 Drawing Divs Spaced

1
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

Comments

Sign in to join the discussion.

MIT Licensed