Making a Bar Chart
This example shows a horizontal bar chart ranking the top 10 most populous countries based on 2018 estimates from the United Nations World Population Prospects. It uses D3 v5 (d3.scaleLinear, d3.scaleBand, d3.axisLeft, d3.axisBottom) to map population values to bar lengths and country names to y-axis positions. The chart customizes axes by removing domain lines and tick marks, and formats tick labels with a custom function replacing 'G' (giga) with 'B' (billion). Population data is read from a CSV file and multiplied by 1000 before rendering as SVG rectangles.
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.