d3.selectAll() creates a D3 selection containing every DOM element that matches a CSS-style selector. Use it when a visualization must manipulate multiple elements rather than only the first match returned by d3.select(). section 2.3 section 2.7
Build selectors with the same forms used in CSS:
- Select every circle with d3.selectAll("circle"). section 2.3
- Combine tag, class, and ID selectors, such as d3.selectAll("h1, .intro"). section 2.3
- Chain selectAll() to a parent selection to limit matching to that selection. section 3.3
Create one bar for each datum
A bar chart can begin with an SVG selection and an empty selection of rectangles: svg.selectAll("rect").data(data).join("rect"). The selector identifies the elements to bind, data() supplies the dataset, and join("rect") creates one rectangle for each row. section 3.3 section 3.6
Figure 2.7 DOM elements returned by the d3.selectAll() method
Visualizes the DOM elements returned by d3.selectAll(). section 2.3
