Making a Bar Chart
✓ Published0🌍 Public
This example demonstrates how to build a simple, horizontal bar chart using D3 v5 and SVG. It displays population data for ten countries, with bars sized proportionally to each nation’s population in thousands. The code uses `d3.csv` to load the data, then applies `scaleLinear` for the x-axis and `scaleBand` for the y-axis to position and size the rectangles. The chart is rendered entirely with SVG `<rect>` elements, with the population values converted to numbers before scaling.
AI-generated descriptionMIT Licensed