What it does
Distinct Colors generates category palettes as an array of chroma.js objects under the ISC licence. Its options bound hue, chroma and lightness while allowing the requested palette size to follow the data.
Call distinctColors with a count and the colour-space ranges appropriate to the chart. Hue limits use degrees from zero to 360; chroma and lightness limits use zero to 100. The library returns colour objects for the application to format or pass into a plotting workflow.
Two controls govern the generation work. samples sets the candidate pool, with 800 by default. quality sets the maximum k-means convergence steps, defaulting to 50, and processing can stop early once the result converges. These settings describe the search rather than a readability guarantee for every category count.
The package is available under the ISC licence.
Strengths
- The palette count can follow a changing category list.
- Colour-space bounds restrict the generated set.
- Candidate sampling and convergence work are configurable.
Watch out for
- Results are chroma.js objects rather than a ready-made array of CSS strings.
Best for
- JavaScript charts generating palettes within chosen colour ranges
Sources
- Distinct Colors options, outputs and ISC licence (Oct 27, 2026)
