I have some code that generates image of a pie chart. It’s a general purpose class, so any number of slices can be given as input. Now I have problem picking good colors for the slices. Is there some algorithm that is good at that?
Colors need to follow some rules:
- they need to look nice
- adjacent colors should not be similar (blue next to green is a no-go)
- pie background color is white, so white is out of option
Some algorithm manipulating with RGB values would be a preferred solution.
I would pre-compile a list of about 20 colors, then start repeating with the 2nd color. This way you won’t break your second rule. Also, if someone makes a pie chart with more than 20 slices, they have bigger problems. 🙂