Skip to main content
Public

Share visualization

Loading preview…

axes Bar Chart

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

axes Bar Chart

1
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'} /> ))}

Comments

Sign in to join the discussion.

MIT Licensed