Locating ends of a DLine in Pixels.

TeeChart for ActiveX, COM and ASP
Post Reply
tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Locating ends of a DLine in Pixels.

Post by tirby » Wed May 29, 2013 5:24 pm

Hi,

I've drawn a DrawLine on my graph, so now how do I find the ends in pixels?

I'm pretty sure this is easy, I'm just not seeing it...

Thanks!

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Locating ends of a DLine in Pixels.

Post by Yeray » Thu May 30, 2013 2:40 pm

Hi,

Being ChartTool1 your TDrawLineTool, and being the line you want to check the one with index 0, the positions in axis values are:

Code: Select all

ChartTool1.Lines[0].StartPos.X
ChartTool1.Lines[0].StartPos.Y
ChartTool1.Lines[0].EndPos.X
ChartTool1.Lines[0].EndPos.Y
Then, you should use the axes CalcPosValue function to transform axis values to pixels. Ie:

Code: Select all

XStartPixel:=Chart1.Axes.Bottom.CalcPosValue(ChartTool1.Lines[0].StartPos.X);
YStartPixel:=Chart1.Axes.Left.CalcPosValue(ChartTool1.Lines[0].StartPos.Y);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Locating ends of a DLine in Pixels.

Post by tirby » Mon Jun 03, 2013 3:58 pm

Thanks Yeray!

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Locating ends of a DLine in Pixels.

Post by tirby » Mon Jun 03, 2013 10:51 pm

Ok,

The above code does give me the info I need, however, it doesn't seem to give me the info I need when the Zoom function has been used.

When zooming in on an end of the DLine, the resulting view is expanded, but the CalcXPosValue(a) and CalcYPosValue(a) returns the same pixel value(s) as when the view is not Zoomed.

I can't figure out what parameter(s) are changed when the Zoom function is used.
Is there a "ZoomXFactor, ZoomYFactor" I can access?
Can you assist?

Thanks!

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Locating ends of a DLine in Pixels.

Post by Yeray » Tue Jun 04, 2013 9:59 am

Hi,

Try forcing a chart repaint:

Code: Select all

TChart1.Environment.InternalRepaint
at the beginning of the OnZoom event. After it, the chart should have updated its internal values and the Calc* functions should work fine then.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Locating ends of a DLine in Pixels.

Post by tirby » Tue Jun 04, 2013 2:55 pm

Thanks Yeray!
That solved the problem.

Post Reply