Published
Edited
May 9, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
litColorRange = colorRange.map((c) => d3.color(c).brighter(0.5).formatHex())
Insert cell
darkColorRange = litColorRange.map((c) => d3.color(c).darker(2).formatHex())
Insert cell
function getColorRange(domain, scheme) {

const scale = Plot.scale({
color: {
type: "categorical",
scheme: scheme,
domain: domain
}
});

return domain.map((d) => scale.apply(d));
}

Insert cell
genConstArray = (name, colors) => `const ${name} = [\n ${colors.map((c) => quote(c)).join(",\n ")}\n];`;
Insert cell
quote = (s) => `"${s}"`;
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more