Skip to main content
Public

Share visualization

Loading preview…

Refactored 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

Refactored Bar Chart

1
Sstephanie0215
Last edited Sep 29, 2022
Created on Sep 29, 2022

This example presents a horizontal bar chart that ranks the top ten countries by their 2020 population. It demonstrates how D3’s scale functions and React state can be combined to build a clean, interactive visualization. The chart uses a band scale for the categorical y-axis and a linear scale for the continuous x-axis. Axis tick marks and labels are generated with custom React components, while bars are drawn as SVG rectangles. Data is loaded from a remote CSV file using the D3 `csv` method and managed through React’s `useState` and `useEffect` hooks.

AI-generated description

A program that loads in some data using D3 utilities, and uses REACT state to keep track of the data.

Comments

Sign in to join the discussion.

MIT Licensed