Skip to main content
Public

Share visualization

Loading preview…

Making a Bar Chart

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

Making a Bar Chart

1
CConnor Trump
Last edited Oct 10, 2021
Created on Oct 10, 2021
Forked from Face

This example shows a horizontal bar chart of population by country, ordered alphabetically and scaled so the bar lengths are proportional to population values. Built with D3 v7 in React, it uses `select`, `csv`, `scaleLinear`, `scaleBand`, `axisLeft`, and `axisBottom` to load data, map population to pixel widths and countries to vertical bands, then render SVG rectangles. The dark green bars are drawn inside a translated group with a margin-based layout. Population values from the CSV are multiplied by 1000 before scaling, and axes are placed with D3’s positioning transforms.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.

Comments

Sign in to join the discussion.

MIT Licensed