🌍 Public
Viewing a saved revision (read-only)
a70fd26b0a97439e8a14ee02f86055a8
data join
This example demonstrates the D3 data join pattern by binding an array of city population objects to SVG rectangles and text labels, producing a simple horizontal bar chart. The code uses `select` and `data` from D3 v7, with the `.join` method to create elements for each datapoint. Rectangles are sized proportionally to population via a scale factor, while a separate join on a `.labels` group renders each city’s name. The SVG canvas is fixed at 2000×2000, with five cities hardcoded in the script.
AI-generated descriptionA demonstration of how to start using D3 version 6.