🌍 Public
Viewing a saved revision (read-only)
2b585c68bc994537b6383e113adffb20
Making a Barchart
This example shows a horizontal bar chart ranking ten countries by population, with the longest bar representing China and the shortest representing Mexico. The bars are rendered as SVG rectangles, with widths proportional to population values read from a local CSV file and scaled using `d3.scaleLinear`. Country names are positioned along the vertical axis using `d3.scaleBand` for categorical spacing. The code loads data with `d3.csv`, converts population strings to numbers, and appends rectangles via `selectAll` and `enter`. The chart uses D3 v5.
AI-generated description