🌍 Public
Viewing a saved revision (read-only)
f4a68115bc4b421688c416091d4faa51
D3 Grouped Selections
This example demonstrates a grouped selection pattern in D3, where the top 10 countries by population from the UN population estimates dataset are rendered as SVG groups, each containing a bar and a text label. The visualization shows a bar chart with country names on the x-axis and population values on the y-axis, using `d3.scaleBand` and `d3.scaleLinear`. The core technique uses `.selectAll('g.mark').join()` with an enter function that appends both a `rect` and `text` element per group, then updates their attributes via nested `.select()` calls. The code imports from `d3` and uses the `@curran/responsive-axes` library for axis handling.
AI-generated descriptionA responsive bar chart.