Making a Barchart
✓ Published0🌍 Public
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 descriptionMIT Licensed