Hello ,
I am facing a small problem , I am creating lines programmtically and want to have each line different color , but what actullay happening is that all lines have the same color, so can some help me, following is the code.
regrads
Trimble
-----------------------------------------------------------------------------------------------------------
void UpdateChart()
{
tChart1.Series.Clear();
byte color_value=255;
foreach (int i in dic.Keys )
{
byte[] bytes = new byte[4];
Random r = new Random();
r.NextBytes(bytes);
List<Cala> ex = dic.ToList();
Steema.TeeChart.Silverlight.Styles.Line line = new Steema.TeeChart.Silverlight.Styles.Line();
Color color = new Color();
int a = (byte)color_value << 5;
int b = (byte)color_value << 3;
int c = (byte)color_value >> 3;
int d = (byte)color_value >> 2;
color = Color.FromArgb((byte)a,(byte)b,(byte)c,(byte)d);
line.Color = color;
foreach (Cala e in ex)
{
line.Add(e.azi, e.elev);
//series.Add(line);
}
tChart1.Series.Add(line);
}
The color of line doesnot change
Re: The color of line doesnot change
Hi Trimble,
Try declaring your Random r out of the for loop. The Randoms are "false randoms" as they always return the same sequence of numbers for a given seed. So, since you are creating a new instance of you random object everytime, the sequence restarts and always give the same value.
Try declaring your Random r out of the for loop. The Randoms are "false randoms" as they always return the same sequence of numbers for a given seed. So, since you are creating a new instance of you random object everytime, the sequence restarts and always give the same value.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |