Hello,
I'm sorry for disturbing you, this is not a bug report, just a question.
My problem:
I have a 2D Chart with Line serie. I have to mark the line when the values are over a specified limit with a different color line. I had an idea: I create a new Line serie when values are over the limit. OK. (Or have you got any other idea how to solve this problem?)
When the values are over the limit several times I have to create several series. OK.
But, when I show the Legend, it will show several Lines, but I just want to see only 2 Lines in legend: "Normal" and "Over the limit".
How can I filter the legend, not to show all series?
Best regards,
Gabor Varga
Legend question
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Gabor,
Yes, you can easily do it this way:
Yes, you can easily do it this way:
Code: Select all
private void Form1_Load(object sender, System.EventArgs e)
{
Random RandObj = new Random(100);
for (int i=0;i<100;++i) line1.Add(RandObj.Next());
for (int i=0;i<line1.Count;++i)
if (line1.YValues.Value[i] < 1000000000) //put your threshold here
line1[i].Color=Color.Red;
else
line1[i].Color=Color.Blue;
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Gabor,
This is not possible directly on the line series. However you can get this custom drawing on tChart's canvas on the AfterDraw event doing something like this:
This is not possible directly on the line series. However you can get this custom drawing on tChart's canvas on the AfterDraw event doing something like this:
Code: Select all
private void Form1_Load(object sender, System.EventArgs e)
{
Random RandObj = new Random();
for (int i=0;i<100;++i) line1.Add(RandObj.Next());
for (int i=0;i<line1.Count;++i)
if (line1.YValues.Value[i] < 1000000000) //put your threshold here
line1[i].Color=Color.Red;
else
line1[i].Color=Color.Blue;
}
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
g.ClipRectangle(tChart1.Chart.ChartBounds);
for (int i=1;i<line1.Count;++i)
{
tChart1.Graphics3D.Pen.Color=line1[i].Color;
if (line1[i].Color.R>line1[i].Color.B) tChart1.Graphics3D.Pen.Width=5;
else tChart1.Graphics3D.Pen.Width=2;
tChart1.Graphics3D.Line(line1.CalcXPosValue(line1.XValues.Value[i-1]),
line1.CalcYPosValue(line1.YValues.Value[i-1]),
line1.CalcXPosValue(line1.XValues.Value[i]),
line1.CalcYPosValue(line1.YValues.Value[i]));
}
g.UnClip();
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,
Thank you very much for your quick response.
The solution will be the next:
I have 3 regions: Over Limit, Normal, Under limit like this:
Over Limit
------------------------ limit2
Normal
------------------------ limit1
Under limit
I will create 3 line series "Under limit", "Normal", "Over limit".
I will seperate the values into 3 groups: "Under limit", "Normal", "Over limit". (I have to add "special" values where the line cross the limit.)
I will set the color of the "Normal line" to Transparent when for example the values of "Normal" line is over the limit. (And do this when the values of "Over limit" line in "Normal" or "Under limit" region and so on...)
And now some ascii art...
e.g.: Normal line
"o" = value;
x = "special" values;
/ and \ lines
. = nothing (just to keep the distance beetween characters)
........o.........
......../\........ Over limit (line1.Color = Color.Transparent;)
-----x---x-----------------
..../........\....
...o.........o... Normal (line1.Color = Color.Green);
.../..........\...
-x----------x--------------------
./.............\... Under limit (line1.Color = Color.Transparent;)
o .............o..
Best regards,
Gabor Varga
Thank you very much for your quick response.
The solution will be the next:
I have 3 regions: Over Limit, Normal, Under limit like this:
Over Limit
------------------------ limit2
Normal
------------------------ limit1
Under limit
I will create 3 line series "Under limit", "Normal", "Over limit".
I will seperate the values into 3 groups: "Under limit", "Normal", "Over limit". (I have to add "special" values where the line cross the limit.)
I will set the color of the "Normal line" to Transparent when for example the values of "Normal" line is over the limit. (And do this when the values of "Over limit" line in "Normal" or "Under limit" region and so on...)
And now some ascii art...
e.g.: Normal line
"o" = value;
x = "special" values;
/ and \ lines
. = nothing (just to keep the distance beetween characters)
........o.........
......../\........ Over limit (line1.Color = Color.Transparent;)
-----x---x-----------------
..../........\....
...o.........o... Normal (line1.Color = Color.Green);
.../..........\...
-x----------x--------------------
./.............\... Under limit (line1.Color = Color.Transparent;)
o .............o..
Best regards,
Gabor Varga