Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Making a Barchart

Public visualization

Viewing a saved revision (read-only)

fe16a8d879a8490ebac5a7442cf85490

Making a Barchart

0 stars0🌍 Public
Rrichartothman@gmail.com
Last edited Sep 23, 2023
Created on Sep 23, 2023

This example shows a horizontal bar chart ranking ten countries by population, with the longest bar representing China and the shortest representing Mexico. The bars are rendered as SVG rectangles, with widths proportional to population values read from a local CSV file and scaled using `d3.scaleLinear`. Country names are positioned along the vertical axis using `d3.scaleBand` for categorical spacing. The code loads data with `d3.csv`, converts population strings to numbers, and appends rectangles via `selectAll` and `enter`. The chart uses D3 v5.

AI-generated description