block by tophtucker 87f02769353208d625c4762a02a3ad55

d3 color-legend example

Full Screen

In response to a question on Twitter by @everybody_kurts:

“Hi @mbostock, I was looking at your stacked area chart at At the end of the file, you import swatches from “@d3/color-legend”. I tried finding this on npmjs but to no avail. Is this exclusive to @observablehq only?”

This shows how to use the swatches function from the @d3/color-legend notebook in a plain HTML page. The example data for the swatches (the color scale and margin) is copied from the @d3/stacked-area-chart notebook.