Skip to main content
100%

26. D3 Bar Chart Heights

✓ Published3🌍 Public
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
MIT Licensed

Similar vizzes