Page 1 of 1
Line Color Problem
Posted: Mon Aug 16, 2010 11:21 am
by 13047867
Hello i want to draw in my Graph four lines different color.when i write code, which is belove ,four lines look different color then i wrote as shown in picture.Especially white color looks very bad.Please could you help ,how i can draw different color lines?
Line newLine = new Line();
newLine.LinePen.Width = 5;
series = newLine;
series[0].Color = Color.Red;
series[1].Color = Color.Purple;
series[2].Color = Color.Black;
series[3].Color = Color.Yellow;
Re: Line Color Problem
Posted: Mon Aug 16, 2010 2:23 pm
by yeray
Hi Solutions Gallery BV,
I think you are a little bit mistaken.
I see in your code that "series" is a Line series. Accessing to it's list you are accessing to the points of your series.
I understand you are trying to access to your chart series list, not your series point list, so you should do:
Code: Select all
tChart1.Series[0].Color = Color.Red;
tChart1.Series[1].Color = Color.Purple;
tChart1.Series[2].Color = Color.Black;
tChart1.Series[3].Color = Color.Yellow;
Or also, the same:
Code: Select all
tChart1[0].Color = Color.Red;
tChart1[1].Color = Color.Purple;
tChart1[2].Color = Color.Black;
tChart1[3].Color = Color.Yellow;
Re: Line Color Problem
Posted: Tue Aug 17, 2010 6:21 am
by 13047867
Hello Yeray
I tried the code which you wrote.But it gives error.Error is "System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection"
Thanks
Re: Line Color Problem
Posted: Tue Aug 17, 2010 8:26 am
by 10050769
Hello Solutions Gallery BV,
I tried the code which you wrote.But it gives error.Error is "System.ArgumentOutOfRangeException: Index was out of range.
I think that you need add your lines, previously change color for each lines. Please, try check again,our code using next lines:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
for (int i = 0; i < 4; i++)
{
new Steema.TeeChart.Styles.Line(tChart1.Chart);
tChart1[i].FillSampleValues();
(tChart1[i] as Steema.TeeChart.Styles.Line).LinePen.Width = 5;
}
tChart1.Series[0].Color = Color.Red;
tChart1.Series[1].Color = Color.Purple;
tChart1.Series[2].Color = Color.Black;
tChart1.Series[3].Color = Color.Yellow;
}
Could you say us, if previous code works as you want and is a good solution for your problem?
I hope will helps.
Thanks,