colorDefaults
A set of default color values used when assigning colors based on data.
The categorical scale is CVD-checked: its first eight slots (the identity
tier) are open-color steps chosen to sit inside the OKLCH lightness band,
clear the chroma floor, and stay distinguishable under protanopia and
deuteranopia — validate them with colorValidate. The slot order is the
colorblind-safety mechanism and should not be reshuffled. Slots nine and up
are a lighter second ring of the same hues, for high-cardinality fallback
(past ~8 series, prefer grouping the tail into “Other”).
sequential is the default single-hue anchor for magnitude ramps (blue).
Basic example
Section titled “Basic example”The named slots every chart starts from: dark and light for text and backgrounds, missing for values with no data, on and off for booleans, and sequential as the single hue that magnitude color scales ramp toward. Override any of them through a chart’s colorDefaults config.
import {colorDefaults} from "@d3plus/color";
colorDefaults.dark;
colorDefaults.light;
colorDefaults.missing;
colorDefaults.off;
colorDefaults.on;
colorDefaults.sequential;
Categorical scale
Section titled “Categorical scale”scale is the ordinal scale categories are assigned from, in order. The first eight are the identity tier, chosen and ordered so neighbouring series stay distinguishable under the common forms of color-vision deficiency (check them with colorValidate); the next eight are a lighter ring of the same hues for charts with more series than that.
import {colorDefaults} from "@d3plus/color";
colorDefaults.scale.range();
Parameters
import {colorDefaults} from "@d3plus/color";