Skip to main content
Explore
Solutions
Bespoke Studio
Pricing
Quick Start
Demo
Log in
Send feedback
✕
Tell us what works and what could be better. We read every submission.
Send feedback
✕
Tell us what works and what could be better. We read every submission.
Home
•
Fork Viz
Fork Viz
Create your own copy of this visualization.
Forking from
D3 Grouped Selections
Title
*
Description
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.
Visibility
Public
Private (only you), Pro
Unlisted (anyone with link)
Private work requires Pro.
Upgrade
Cancel
Fork Viz