Assign a random color to a new label

By default, every newly created label is grey. It would be cool if every new label could get a random color (perhaps from a pre-defined palette) instead.

Would save me a lot of time and headache thinking of “appropriate” colors for different labels, and colors balance in a label set.

1 Like

Do you think it would work to give it one of the predefined colors from the color picker?

Yeah, sounds like a good option.

Is it possible to assign random colours? Maybe create random numbers between 1 and 16, round it down to the previous integer and convert it to hexadecimal?

From a technical point of view yes, you could do that. But you usually don’t get great colours when you’re just randomly generating numbers. A better way of doing this is to have a list with colours somewhere and then pick one of them at random.

1 Like

maybe the 16 default console colors, extended to the 256 when needed

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.

I’ve added a first version of this in 3f3d4b1682. New labels will now get a random color from a predefined list.