colorValidate
Validates a chart color palette against the computable accessibility checks.
Default palette
Section titled “Default palette”Runs the categorical accessibility checks against the first eight swatches of the built-in colorDefaults.scale, reporting each check’s pass/warn/fail state and whether the palette clears every hard requirement.
import {colorValidate, colorDefaults} from "@d3plus/color";
colorValidate(colorDefaults.scale.range().slice(0, 8));
Ordinal ramp
Section titled “Ordinal ramp”Pass {ordinal: true} to validate an ordered single-hue ramp instead: it checks monotone lightness, visible step gaps, a light end that still clears the surface, and a single hue — the categorical checks would fail a correct ramp by design.
import {colorValidate, colorRamp, colorDefaults} from "@d3plus/color";
colorValidate(colorRamp(colorDefaults.sequential, 5, {ordinal: true}), {
ordinal: true,
});
Parameters
import {colorValidate} from "@d3plus/color";