Page 1 of 1
Calculating size of a point
Posted: Tue Jul 10, 2007 11:15 pm
by 8739068
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.
Posted: Thu Jul 12, 2007 7:40 am
by Chris
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.
Difficulty getting correct values
Posted: Mon Jul 16, 2007 8:50 pm
by 8739068
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?
Posted: Tue Jul 17, 2007 1:32 pm
by Chris
Hello!
Have you tried moving your code into the TChart.BeforeDraw event?
Using BeforeDrawSeries
Posted: Tue Jul 17, 2007 2:31 pm
by 8739068
I tried BeforeDrawSeries and that did not work for me. I overlooked the BeforeDraw event. That seems to address my needs.
Thanks.
troubles calculating accurate distance
Posted: Tue Jul 17, 2007 9:37 pm
by 8739068
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?
Still waiting on a response
Posted: Fri Jul 20, 2007 4:03 pm
by 8739068
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.
Posted: Mon Jul 23, 2007 11:30 am
by Chris
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.
Sample project has been uploaded
Posted: Mon Jul 23, 2007 5:03 pm
by 8739068
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.
Did you receive my project?
Posted: Tue Jul 24, 2007 8:54 pm
by 8739068
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
Posted: Thu Jul 26, 2007 6:26 am
by Chris
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!