Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of D3 Starter

Public visualization

Viewing a saved revision (read-only)

63acb80f817f4213afbd5b78256f52b4

Fork of D3 Starter

0 stars0🌍 Public
PPurva Suresh
Last edited Oct 29, 2026
Created on Oct 29, 2026
Forked from D3 Starter

This example demonstrates how different orderings of categorical data affect the readability of a bar chart, using a slice of a sample CSV dataset filtered for 2023 with CO₂ emissions per capita as the bar length. Three buttons toggle the chart’s sort order—alphabetical, by value, or by a derived attribute computed as total CO₂ divided by population. The chart is implemented as a reusable function following the closure pattern, using d3.scaleBand, d3.scaleLinear, d3.axisBottom, and d3.axisLeft to render SVG elements, with chainable getter/setters for its properties.

AI-generated description