Assign a random color to a new label

I recently created random colors for charts where we didn’t know the amount of necessary colors.

It’s not easy but possible when you consider some color theory.

Helping is the new way of WCAG3 for calculating color contrast APCA in combination with the OKlch color model (see also the color picker).

This can be visualised greatly with huetone

I also found d3-scale-chromatic very interesting.