Skip to content

paletteColors

paletteColors(palette, n, reverse?): string[] | undefined

Defined in: packages/core/src/classify/palettes.ts:81

n colours from a palette, or undefined when it does not offer n.

ParameterTypeDefault value
palettePaletteDataundefined
nnumberundefined
reversebooleanfalse

string[] | undefined

Below the palette’s smallest size (ColorBrewer starts at 3) the smallest set is sampled evenly, keeping both ends — a quantile computation whose values tie can collapse to two classes, and those should still read as “low” and “high”. Above the largest size there is no honest answer, so the caller reports it.