Skip to main content
100%

scaling bar chart

✓ Published1🌍 Public
GGuitong Li
Last edited Feb 3, 2022
Created on Feb 3, 2022
Forked from color pie

This visualization shows the populations of the top 10 most populous countries using a horizontal bar chart, with each bar’s length representing the population value from the United Nations 2018 estimate. The chart is rendered as an SVG within a React app, and the code uses `scaleBand` for the categorical country axis and `scaleLinear` for the quantitative population axis. The D3 `max` function sets the domain for the linear scale, while the `bandwidth()` method determines each bar’s height. Data is loaded from a CSV file via the `csv` function, and the bars are drawn as SVG `rect` elements.

AI-generated description

This 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.

See also the first bar chart visualization that this one builds on: Making a Bar Chart.

MIT Licensed

Similar vizzes