Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Making a bar chart!

Public visualization

Viewing a saved revision (read-only)

6d7822222fb745dbb6c20d3ae14a5f5d

Making a bar chart!

0 stars1🌍 Public
MmangoJ0106
Last edited Mar 21, 2020
Created on Mar 19, 2020

This example shows a horizontal bar chart of population data for nine countries, with the country names on the y-axis and population counts on the x-axis. It loads data from a CSV file, then uses d3.scaleBand for the categorical country axis and d3.scaleLinear for the continuous population axis, with d3.axisLeft and d3.axisBottom for tick labels. Bars are rendered as SVG rect elements with a steelblue fill, and the chart is drawn in an SVG canvas with margins calculated from the viewport dimensions.

AI-generated description

Loading the d3 script from UNPKG puts a d3 variable in the global namespace. (Take out "browse" from that link to load it.