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!
Locating ends of a DLine in Pixels.
Re: Locating ends of a DLine in Pixels.
Hi,
Being ChartTool1 your TDrawLineTool, and being the line you want to check the one with index 0, the positions in axis values are:
Then, you should use the axes CalcPosValue function to transform axis values to pixels. Ie:
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
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Locating ends of a DLine in Pixels.
Thanks Yeray!
Re: Locating ends of a DLine in Pixels.
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!
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!
Re: Locating ends of a DLine in Pixels.
Hi,
Try forcing a chart repaint:
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.
Try forcing a chart repaint:
Code: Select all
TChart1.Environment.InternalRepaint
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Locating ends of a DLine in Pixels.
Thanks Yeray!
That solved the problem.
That solved the problem.