Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

axes Bar Chart

Public visualization

Viewing a saved revision (read-only)

60492ce87c7b4d9b8c750515ca25ae88

axes Bar Chart

0 stars1🌍 Public
MMATTE-blz
Last edited Mar 31, 2021
Created on Mar 30, 2021

This bar chart displays the top 10 countries by population in 2020, using data from a UN Population CSV file. It renders with React and SVG, where D3’s `scaleBand` positions the country labels on the y-axis and `scaleLinear` maps population values to bar widths on the x-axis. The code manually generates gridlines and tick labels using `xScale.ticks()` and maps over `yScale.domain()` for text elements, rather than using D3’s axis components. Each rectangle’s width is set with `xScale(d.Population)`, and its height uses `yScale.bandwidth()`.

AI-generated description

{xScale.ticks().map((tickValue) => ( <line x1={xScale(tickValue)} y1={0} x2={xScale(tickValue)} y2={innerHeight} stroke={'black'} /> ))}