Making a Bar Chart
✓ Published1🌍 Public
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 descriptionA bare minimum HTML page demonstrating use of CSS and JavaScript.
See also React Starter.
MIT Licensed