Skip to main content
Public

Share visualization

Loading preview…

26. D3 Bar Chart Heights

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

26. D3 Bar Chart Heights

0 stars3Public
Aamakanju@nyit.edu
Last edited Oct 1, 2026
Created on Feb 9, 2026

A simple bar chart displays twenty numeric values as vertical SVG rectangles. The chart uses a fixed width of 500 pixels and height of 100 pixels, with each bar’s height scaled by a factor of four. The code creates the visualization by selecting the body, appending an SVG element, and binding the dataset using `d3.select`, `.data`, and `.enter()`. Rectangles are positioned using `attr('x')` and `attr('y')`, with width calculated by dividing the total width by the number of data points, minus a one-pixel padding.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed