Page 1 of 1

The color of line doesnot change

Posted: Thu Jun 17, 2010 12:38 pm
by 15654835
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);



}

Re: The color of line doesnot change

Posted: Fri Jun 18, 2010 3:55 pm
by yeray
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.