Calculating size of a point

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Calculating size of a point

Post by Mike Jones » Tue Jul 10, 2007 11:15 pm

I have a need to calculate the size of points in a Steema.TeeChart.Styles.Points series. I found that I can set the horizontal and verticle sizes and it will create an oval shaped point.

The points I am generating are evenly spaced. There is a horizontal spacing and a vertical spacing in the 2D chart that I am generating.

I want to calculate the horizontal and vertical sizes based on the following equation:

Width of point = ((width of chart)/(X max - X min)) * X increment

similarly with the vertical

Height of point = ((Height of chart)/(Y max - Y min)) * Y increment

I am setting Steema.TeeChart.Styles.Points.Pointer.HorizSize and Steema.TeeChart.Styles.Points.Pointer.VertSize

My questions are:

1. How do I get the Height and Width of the Chart in pixels?

2. Is there an event that is raised if the chart is zoomed? I will have to recalculate my point size if this occurs.

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Thu Jul 12, 2007 7:40 am

Hello!
1. How do I get the Height and Width of the Chart in pixels?
tChart1.Chart.ChartRect will give you the rectangle which is bounded by the chart axes (the area in which the series is painted) and tChart1.Chart.ChartBounds will give you the rectangle within which the entire chart is painted.
2. Is there an event that is raised if the chart is zoomed? I will have to recalculate my point size if this occurs.
Yes, indeed, you can use the TChart.Zoomed event.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Difficulty getting correct values

Post by Mike Jones » Mon Jul 16, 2007 8:50 pm

Using the Zoomed event seems to work.

I need to recalculate the point sizes when the control is resized as well. Using the Resize event does not work for me, because while in the Resize event, the values in ChartRect are the old values before the resize. I need the sizes after it has resized.

Can you help me identify how to either get an event after the resize is complete, or find the new sizes while in the Resize event?

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Tue Jul 17, 2007 1:32 pm

Hello!

Have you tried moving your code into the TChart.BeforeDraw event?
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Using BeforeDrawSeries

Post by Mike Jones » Tue Jul 17, 2007 2:31 pm

I tried BeforeDrawSeries and that did not work for me. I overlooked the BeforeDraw event. That seems to address my needs.


Thanks.

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

troubles calculating accurate distance

Post by Mike Jones » Tue Jul 17, 2007 9:37 pm

In a simple example series of Steema.Styles.Points looks something like

0.0,1.0
2.0,1.0
4.0,1.0
6.0,1.0
8.0,1.0
10.0,1.0

When these points are shown in a chart the bottom axis goes from -0.8 to +10.8. The major tick marks are 2, 4, 6, 8, 10. When I do a quick watch on the Bottom axis, I can see the internal values being used and that is where I see the values -0.8 to +10.8.

I am trying to calculate programatically the width (and ultimately the height) of a point so that the edges of the point just touch.

I was doing the followng calculation

point width = (chart1.ChartRect.Width) * Increment / (XValues.Maximum - XValues.Minimum)

Where Increment = 2.0, which is the distance between my points along the Bottom Axis.

Using this calculation I am not getting the edges to touch. It seems to be significantly short. I am concerned that when I calculate my point width the the chart is autmatically adjusting the axis and this the value I get chart1.ChartRect.Width is not accurate for my calculations.

Do you have any suggestions?

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Still waiting on a response

Post by Mike Jones » Fri Jul 20, 2007 4:03 pm

I never received a response to my previous question.

After further research it looks like I might be able to use the TChart Control's ability to autosize. I might have to calculate the sizing. I would like some feedback on my issues.

Thanks.

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Jul 23, 2007 11:30 am

Hello,
After further research it looks like I might be able to use the TChart Control's ability to autosize. I might have to calculate the sizing. I would like some feedback on my issues.
It would be greatly appreciated if you could upload a simple example which we can run "as-is" of the issues you have to:
http://www.steema.net/upload/

Please let us know when you've posted something.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Sample project has been uploaded

Post by Mike Jones » Mon Jul 23, 2007 5:03 pm

When you run the sample project, notice that the point sizes will change. The goal is to make them large enough so the vertical and horizonal edges just touch. Sometimes they willl overlap, other times there will be gaps.

Any suggestions to my calculations are welcome.

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Did you receive my project?

Post by Mike Jones » Tue Jul 24, 2007 8:54 pm

I uploaded a VS2005.NET project a couple of days ago. Can you confirm that you received it and when I might expect a response?

Thanks

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Thu Jul 26, 2007 6:26 am

Hello!

As you can see here:
http://www.steema.com/support/public_hols2007.html

yesterday was a public holiday for us at Steema which may explain the slight delay. We'll get back to you as soon as we have something for you!
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Post Reply