🌍 Public
Viewing a saved revision (read-only)
433ddbd143b54173b35134e44712d285
Sequential Color Legend in D3
This example demonstrates how to generate a sequential color legend using Susie Lu’s d3-legend library. It renders a small SVG with a legend title and five color cells, mapping a domain of seven distance values to a red interpolator via `d3.scaleSequential` and `d3.interpolateReds`. The legend is created with `d3.legendColor()`, configured with a title and scale, and attached to an SVG group using a standard D3 selection and `.call()`. The chart uses D3 v7 and d3-legend v2.25.6, rendering entirely as inline SVG.
AI-generated descriptionDemonstration of the use of Susie Lu's d3-legend to display a color legend that uses a sequential color scale.