colorRamp
Builds an n-step single-hue ramp from a pale tint to the given base color,
stepped evenly in OKLab so each step looks equally far from the next.
This replaces lightening in HSL (which desaturates toward pure white and shifts hue, so the pale end loses its identity and can render as white). In OKLab the hue is held fixed and lightness/chroma taper together, so the ramp reads as one hue getting lighter.
Returned lightest→darkest; the darkest step is the base color itself for a continuous ramp.
Basic example
Section titled “Basic example”Builds a six-step ramp from each of three base hues, returned lightest to darkest with the base color itself as the final step; the tint end holds its hue instead of washing out to white.
import {colorRamp} from "@d3plus/color";
colorRamp("#1c7ed6", 6);
colorRamp("#2f9e44", 6);
colorRamp("#ae3ec9", 6);
Ordinal ramp
Section titled “Ordinal ramp”With {ordinal: true} the palest step is held darker so every step still reads as a distinct mark against the surface — the ramp for ordered discrete categories, versus the default continuous ramp whose light end may fade into the background.
import {colorRamp} from "@d3plus/color";
colorRamp("#1c7ed6", 5, {ordinal: true});
colorRamp("#2f9e44", 5, {ordinal: true});
colorRamp("#ae3ec9", 5, {ordinal: true});
Parameters
import {colorRamp} from "@d3plus/color";