in a lecture about data prep and transformation there was a bit about numbers being stored without formatting ;) formatting a number such as 17% should happen at a presentation layer, after visual mappings
also this is not in tidy data format. might still work for some charts but generally you'd want to have it in tidy data (see back in lecture slides for how to do it)
you can easily add a color legend here as described in https://observablehq.com/@d3/color-legend
add a cell in appendix:
import {Legend, Swatches} from "@d3/color-legend"
then add a cell above or below your chart:
Swatches(d3.scaleOrdinal(categories, d3.schemeSpectral[categories.length]))
I was spending a lot of time trying to get it to appear within the same code block. I get confused with the multiple code blocks it is an unhealthy habit but I keep trying to keep it all in one. Not very organized of me.