Screen Point to Chart Coordinates

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bvsimmons
Newbie
Newbie
Posts: 3
Joined: Fri Jul 07, 2017 12:00 am

Screen Point to Chart Coordinates

Post by bvsimmons » Thu Jul 20, 2017 8:04 am

Is there a way to obtain the Chart X and Y coordinates from a screen X, Y (mouse coordinates).

Thanks
Bernard

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

Re: Screen Point to Chart Coordinates

Post by Yeray » Fri Jul 21, 2017 6:36 am

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);
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

bvsimmons
Newbie
Newbie
Posts: 3
Joined: Fri Jul 07, 2017 12:00 am

Re: Screen Point to Chart Coordinates

Post by bvsimmons » Wed Jul 26, 2017 12:30 am

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

bvsimmons
Newbie
Newbie
Posts: 3
Joined: Fri Jul 07, 2017 12:00 am

Re: Screen Point to Chart Coordinates

Post by bvsimmons » Wed Jul 26, 2017 12:52 am

Never mind, I found it, in C++ Builder it's Chart1->Series->CalcXPosValue(.....

Thanks

Bernard

Post Reply