Random Color Picker

Mar 19, 2012 at 4:44 PM

I would like to create a trend with multiple LineSeries, however it would be necessary to pick a different color for each added LineSeries. Is there a color picker function to choose "random" colors, or I would have to do it manually?

Coordinator
Mar 20, 2012 at 5:26 PM

See the DefaultColor property of the PlotModel, you can change this to a list of random colors. The default value uses a predefined palette, not random colors. 

ps. I will change the DefaultColor property to an IList<Color>

Mar 20, 2012 at 5:50 PM

When I add a new LineSeries to the Series list, it plots using the same default color (dark green). However, when I add multiple plots at once (inside the same loop, for example), each lineseries get a different color. That color rotation is what I wanted, however with lineseries added at different moments.

Coordinator
Mar 30, 2012 at 11:20 AM

Sorry, I don't quite understand. Is this a bug in the library? Do you add all series to the same plot?

I would like the plot always to generate the same colors (no randomness), if you want random colors to be generated when adding new series, this should be handled by your code.

Jan 9, 2014 at 4:27 PM
Edited Jan 9, 2014 at 4:28 PM
I believe I have a good handle with regard to random colors being assigned when adding LineSeries to a plot.

If you add a new LineSeries without its Color property set, the LineSeries will be assigned a Color (assigned to the ActualColor property) based on the number of LineSeries in the plot with its Color property still set to its default value (0x000001). Therefore, if you have 5 LineSeries in a plot of which 2 still have their Color property set to default, the Color assigned to the third LineSeries will be the third Color in the DefaultColors IList<> collection.

If you elect to assign a Color to a LineSeries (thereby assigning a non-default value to its Color property) and Refresh the plot, all other LineSeries may have their ActualColor property re-assigned a new color based on the number of LineSeries with default Colors remaining in the Series collection.

For example: First four colors in the DefaultColors IList<> collection are Red, Blue, Brown and Violet. The first LineSeries added with a default Color will have Red assigned to its ActualColor. Blue for the second, Brown for the third. Now, if you assign say Yellow to the second LineSeries and refresh the plot, you will find that the first LineSeries remains Red but the third LineSeries (previously Brown) will be re-assigned to Blue (since its the next in line in the IList<>).

In short, default / random colors are only assigned if their Color property is set to its default value of 0x000001. Once added to a plot, updating its Color can affect the color of other LineSeries (defpending on their order in the Series collection with regard to other LineSeries with a default Color property.

Hope this helps and thank you for this excellent library.

Cheers,
Jean
Coordinator
Jan 10, 2014 at 8:20 AM
Thanks Jean, great explanation!