SeriesRegionTool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

SeriesRegionTool

Post by Verane » Wed Sep 12, 2007 2:27 pm

Hi,

I would like to color an area below a serie but above a line (drawn using the lineTo function of the canvas).
I have tried to go through all pixels of the teeChart and color those that were between my line and my serie, but this is very slow.
I have seen in this forum something about SeriesRegionTool to color under series. How do I use it? Is there an example somewhere?
With this tool, it is possible to color area under a serie but above a line ?

Thanks,
Verane.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Sep 12, 2007 2:32 pm

Hi Verane,

Yes, this is possible. You'll find an example of this at What's New?\Welcome !\New Chart Tools\Area under the curve in the features demo available at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

Post by Verane » Wed Sep 12, 2007 2:50 pm

Thanks, I have seen the example.
Is it possible even if my line is not parallel to the bottom axis ?

Thanks
Verane.

Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

Post by Verane » Thu Sep 13, 2007 9:25 am

Hi,
I have found no solution to tell that the origin is not parallel to the bottom axis.
So my next idea was to create a fake fast line serie that is transpartent and that is the same as my line.
So now I have two fast line series, whose interserction is a closed region.
But I do not see any color.

If I add only one or the other serie, it colors the area under this serie.
But is it capable to color the intersection of two series?

Here is a part of my code, may be I do something wrong:
mSeriesRegionTool = new SeriesRegionTool(chart.Chart);
mSeriesRegionTool.Active = true;
mSeriesRegionTool.AutoBound = false;
mSeriesRegionTool.Color = Color.LightBlue;
mSeriesRegionTool.DrawBehindSeries = true;
Series seriesToDefineRegion = new Series(null);
seriesToDefineRegion.Add(mRawDataSerie);
seriesToDefineRegion.Add(mFakeSerieForOneBaseLine);
mSeriesRegionTool.Series = seriesToDefineRegion;
mSeriesRegionTool.UseOrigin = false;

Thanks in advance for your help,
Verane.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Sep 13, 2007 10:54 am

Hi Verane,

TeeChart Pro VCL and ActiveX versions have SeriesBand tool which does what you requests. For now, this hasn't been implemented in the .NET version but it is a high priority item in our wish-list to be implemented for next releases.

I've also added a feature request for SeriesRegion tool to support origin not being parallel to the bottom axis.

In the meantime, a workaround would be combining SeriesRegion tool and polygon drawing as shown here:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.Axes.Left.AutomaticMinimum = false;
			tChart1.Axes.Left.Minimum = 0;

			Steema.TeeChart.Tools.SeriesRegionTool seriesRegion1 = new Steema.TeeChart.Tools.SeriesRegionTool(tChart1.Chart);
			seriesRegion1.Series = line1;
			seriesRegion1.UseOrigin = true;
			seriesRegion1.Origin = line1.MinYValue();
			seriesRegion1.Pen.Visible = false;
		}

		private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			Rectangle rect = tChart1.Chart.ChartRect;
			int tmpPos = tChart1[0].CalcYPosValue(tChart1[0].MinYValue());

			g.Pen.Color = ((Steema.TeeChart.Styles.Line)tChart1[0]).LinePen.Color;
			g.Line(rect.Left, rect.Bottom, rect.Right, tmpPos);

			Point[] myPolygon = new Point[3];

			g.Pen.Visible = false;
			g.Brush.Color = ((Steema.TeeChart.Tools.SeriesRegionTool)tChart1.Tools[0]).Brush.Color;
			
			myPolygon[0] = new Point(rect.Left, rect.Bottom);
			myPolygon[1] = new Point(rect.Right, tmpPos);
			myPolygon[2] = new Point(rect.Left, tmpPos);
			
			g.Polygon(myPolygon);			
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

Post by Verane » Thu Sep 13, 2007 12:03 pm

Hi Narcis,

Thanks for the answer.
Could tell me roughly when you plan to have SeriesBand and origin not parallel to bottom axis implemented ?

I have looked at your workaround and there is something I don't understand.
The principle is to draw more than needed and then cover the excedent part with a polygon ? Or in reverse to draw fewer than needed and add a polygon ?
My serie is like a sinusoid, so I am not sure this will fit exaclty.
Do you want me to send a picture of what I want to do ? If yes, on which email address ?

Thanks
Verane.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Sep 13, 2007 12:13 pm

Hi Verane,
Could tell me roughly when you plan to have SeriesBand and origin not parallel to bottom axis implemented ?
I can't tell you for now but it's most likely that SeriesBand will be implemented sooner as it only has to be ported from the VCL version. I'd recommend you to be aware at this forum for new release announcements and whats being implemented/fixed on them.
The principle is to draw more than needed and then cover the excedent part with a polygon ? Or in reverse to draw fewer than needed and add a polygon ?
My example is based on the 2nd option.
My serie is like a sinusoid, so I am not sure this will fit exaclty.
The series wouldn't be a problem. What can be problematic here is the line you draw directly to the chart canvas as I did in the AfterDraw event. This can make SeriesBand more suitable.
Do you want me to send a picture of what I want to do ? If yes, on which email address ?


Yes please, you can post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

Post by Verane » Thu Sep 13, 2007 12:16 pm

Another question related to this topic:
I can have colored part under the line I have specified as origin. How this is possible ? I can send you a screen copy to show you. (same question as previous post : which address should I use?).
Verane.

Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

Post by Verane » Thu Sep 13, 2007 12:51 pm

I have uploaded three bmp files on your updload page : verane1, verane2 and verane3.

verane1 shows what happened when I use a SeriesRegionTool with Origin = the lowest point of my intersecting line (the green marker).
I have too much things colored in light blue.
I thought it was what you explained in you example as in your example you do this:
seriesRegion1.Origin = line1.MinYValue();
So that what I asked you about the two options...
I still don't understand how your example can be based on the second option. May be with the screen copy you can explain me what I don't understand ?


In verane2, this is an example where I have put my origin value to roughly -0.7 (it passes by the green marker), but I have colored part under -0.7. Why ?

In verane3, my origin pass through the red marker (I think this is the start before adding a polygon and implementing option 2).
In that case, why for X=40 to X=48, there is some color above the signal ? The color should be only under the signal, no ?
You told me that it is not a problem if my serie is a sinusoid, but the part in white between the signal and the line I would like to color is not exactly a triangle isnt' it ??

Thanks
Verane.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Sep 13, 2007 2:54 pm

Hi Verane,
I can have colored part under the line I have specified as origin. How this is possible ?


Yes, this is possible drawing another polygon as shown in my previous example.
verane1 shows what happened when I use a SeriesRegionTool with Origin = the lowest point of my intersecting line (the green marker).
I have too much things colored in light blue.
I thought it was what you explained in you example as in your example you do this:
seriesRegion1.Origin = line1.MinYValue();
So that what I asked you about the two options...
I still don't understand how your example can be based on the second option. May be with the screen copy you can explain me what I don't understand ?
Yes, the image below is how my example looks like. I've changed the custom drawn polygon to be in red and the region tool in white.

Image
In verane2, this is an example where I have put my origin value to roughly -0.7 (it passes by the green marker), but I have colored part under -0.7. Why ?
This is because this tool paints all the regions from the series to the origin (above or below the series) from the lower to the upper limit.
In verane3, my origin pass through the red marker (I think this is the start before adding a polygon and implementing option 2).
In that case, why for X=40 to X=48, there is some color above the signal ? The color should be only under the signal, no ?
You told me that it is not a problem if my serie is a sinusoid, but the part in white between the signal and the line I would like to color is not exactly a triangle isnt' it ??
This is expected behaviour. The triangle is most likely because you set the region tool lower limit to 40 and the upper limit to the red marker, didn't you?

It seems very complicated to me achieving the functionality you request without SeriesBand tool. With this tool combined with CrossPoints function you could precisely define the area you want painted.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

Post by Verane » Thu Sep 13, 2007 3:23 pm

Hi Narcis
Yes it seems impossible to do what I need to do (color one peak of my sinusoid only) with the SeriesRegionTool.
Is there any other option to do that ?
I tried to scan all the chart pixels and test if a particular pixel was inside the surface I wanted to color. If yes I colored it using Pixel() function.

But the problem is:
If I do not do this in the after draw, each time the chart refreshes itself my color goes away.
If I do this in the after draw it is VERY VERY slow and don't draw exactly what I expect.

I can also negociate to implement this functionnality later, but I need to know when SeriesBand would be implemented (is it one day, one week, one month, one year ??). If your target is after the end of our project, I will have to search a workaround, else I can wait. So having a rough idea of the delay is very important for me.

Thanks
Verane.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Sep 14, 2007 10:08 am

Hi Verane,

We've reviewed SeriesBand implementation on we think we can have it ready in a new maintenance release in about 10 days. Is this acceptable for you? Otherwise we will help you finding a workaround to achieve this.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Verane
Newbie
Newbie
Posts: 8
Joined: Wed Jul 18, 2007 12:00 am

Post by Verane » Fri Sep 14, 2007 11:57 am

Hi Narcis,
Yes 10 days is acceptable for us.
Thank you,
Verane.

Post Reply