Skip to main content
Public

Share visualization

Send this visualization to others.

25. D3 Bar Chart Widths

Public visualization

By tokunbo-makanju on VizHub

LinkedIn caption

LinkedIn cannot prefill the post text. Copy the caption, then paste it in LinkedIn. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code

The embed preserves the visualization's visibility and project dataset permissions.

Download & exportHTML, source ZIP and authorized project data

Source ZIP contains editable visualization files; it does not include project datasets. Standalone HTML is available where authorized and packages readable referenced data for offline use. Dataset ZIP requires project read permission.

Standalone HTMLSource ZIP
Publishing & handoffCopy a client maintenance summary

Includes the canonical link, visibility, and available export formats. Confirm dataset attribution, licensing and maintenance responsibilities with the publisher.

25. D3 Bar Chart Widths

0 stars1Public
Aamakanju@nyit.edu
Last edited Feb 12, 2026
Created on Feb 9, 2026

This example demonstrates a bar chart with dynamic widths and spacing. It renders 20 rectangles in an SVG container, positioning each bar horizontally and calculating its width based on the dataset length with a fixed padding. The chart uses D3.js version 4.5.0, applying the `selectAll`, `data`, and `enter` pattern to bind the array of numbers to SVG `rect` elements. All bars are drawn with a constant height of 100 pixels, and the x-coordinates are computed using the index multiplied by the width divided by the dataset size.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed