Public
Edited
Sep 6, 2024
2 forks
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sequentialPaletteOklch = sequentialPalette.map(([l, c, h]) =>
new Color(`oklch(${l} ${c} ${h})`).toString()
)
Insert cell
sequentialPaletteHexCodes = sequentialPalette
.map(([l, c, h]) => new Color("oklch", [l, c, h]))
.map((color) => color.to("srgb").toString({ format: "hex" }))
Insert cell
colorOkLchArr = new Color(inputColor).to("oklch").coords
Insert cell
sequentialPalette = {
const [l, c, h] = colorOkLchArr;
const palette = lightnessValues.map((value, index) => [
value,
chromaValues[index],
h
]);
return palette;
}
Insert cell
scale = {
if (scaleType === "Linear") {
return d3.scaleLinear;
} else if (scaleType === "Square Root") {
return d3.scaleSqrt;
} else {
return d3.scalePow;
}
}
Insert cell
lightnessScale = {
const ls = scale([0, numberColors - 1], [maxLightness, minLightness]);
if (scaleType === "Exponential") {
ls.exponent(exponent);
}
return ls;
}
Insert cell
chromaScale = {
const cs = scale([0, numberColors - 1], [minChroma, maxChroma]);
if (scaleType === "Exponential") {
cs.exponent(exponent);
}
return cs;
}
Insert cell
lightnessValues = Array.from({ length: numberColors }).map((_, index) =>
lightnessScale(index)
)
Insert cell
chromaValues = Array.from({ length: numberColors }).map((_, index) =>
chromaScale(index)
)
Insert cell
format = d3.format(".2f")
Insert cell
Insert cell
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