Page 1 of 1
Screen Point to Chart Coordinates
Posted: Thu Jul 20, 2017 8:04 am
by 16481290
Is there a way to obtain the Chart X and Y coordinates from a screen X, Y (mouse coordinates).
Thanks
Bernard
Re: Screen Point to Chart Coordinates
Posted: Fri Jul 21, 2017 6:36 am
by yeray
Hello,
You can use the Axis' CalcPosPoint to transform screen pixels to axis values. Ie:
Code: Select all
var XPixel: Integer;
XValue: Double;
//...
XValue:=Chart1.Axes.Bottom.CalcPosPoint(XPixel);
Note you can also transform Axis values to screen pixels with CalcPosValue function. Ie:
Code: Select all
var XPixel: Integer;
XValue: Double;
//...
XPixel:=Chart1.Axes.Bottom.CalcPosValue(XValue);
Another pair useful functions is the Series' CalcXPos/CalcYPos, returning the pixel position for a given ValueIndex. Ie:
Code: Select all
var XPixel, YPixel, ValueIndex: Integer;
Series1: TPointSeries;
//...
XPixel:=Series1.CalcXPos(ValueIndex);
YPixel:=Series1.CalcYPos(ValueIndex);
Re: Screen Point to Chart Coordinates
Posted: Wed Jul 26, 2017 12:30 am
by 16481290
Thanks for your response.
Where can I find the function 'CalcPosPixel' I have searched all of the directories under Steema TeeChart Pro VCL FMX 2017.22 but have not found it.
Bernard
Re: Screen Point to Chart Coordinates
Posted: Wed Jul 26, 2017 12:52 am
by 16481290
Never mind, I found it, in C++ Builder it's Chart1->Series->CalcXPosValue(.....
Thanks
Bernard