Making a Bar Chart
This example visualizes the 2018 populations of the top 10 most populous countries from United Nations data, presented as a horizontal bar chart. The chart ranks countries by population, with a steelblue fill for each bar and customized D3 axes that remove domain lines and use a tick format converting G to B (e.g., billions). Using d3.csv, d3.scaleLinear, and d3.scaleBand, the code maps population values to pixel widths and country names to vertical bands. The SVG rendering, with margins and axis labels, demonstrates how to structure axes in D3 v5.
AI-generated descriptionThis bar chart shows population of the top 10 most populous countries. The data comes from the year 2018 estimate in United Nations: World Population Prospects 2017. It also demonstrates customization of D3 axes.