This is a migrated thread and some comments may be shown as answers.

Line Chart changing colors

2 Answers 108 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 23 Mar 2012, 12:45 PM
Hi,

I have a multiple line chart which may contain more than 10 lines, would i be able to assign a random and different color to it ?

Thanks

2 Answers, 1 is accepted

Sort by
0
Sam
Top achievements
Rank 1
answered on 23 Mar 2012, 04:55 PM
Update:

Have managed to change the line colours by generating a random colour, but how do I change the legend item colours to match the lines here is my code:

Random randomGen = new Random();
KnownColor[] names = (KnownColor[])Enum.GetValues(typeof(KnownColor));
KnownColor randomColorName = names[randomGen.Next(names.Length)];
Color randomColor = Color.FromKnownColor(randomColorName);
 
MDChartSeries.Appearance.LineSeriesAppearance.Color = randomColor;

0
Richard
Top achievements
Rank 1
answered on 26 Mar 2012, 03:45 PM
Sam:

I think you will find a way to programmatically access the RadChart legend marker's and override the auto-generated colors by handling the "BeforeLayout" server-side event in the following forum thread:

RadChart Legend/ Marker Color

Hope this helps!
Tags
Chart (Obsolete)
Asked by
Sam
Top achievements
Rank 1
Answers by
Sam
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or