D3.js Step by Step: Step 3 - Adding a Legend
This example demonstrates a donut chart whose legend identifies each slice by category label, such as “A: <= 0.25 acres” and “G: 5000+ acres.” The chart is rendered as SVG using D3.js v4, with `d3.pie` and `d3.arc` generating the donut shape and `d3.scaleOrdinal` assigning colors from `d3.schemeCategory20`. The legend is built by appending a `g` element for each color domain entry, adding a colored `rect` and a `text` label, and positioning them vertically. All data counts are zero, so the chart displays an empty donut with its legend intact.