Lazarus

Programming => Graphics and Multimedia => TAChart => Topic started by: Davidous on June 28, 2019, 11:21:57 am

Title: Coordinates of chart rectangle
Post by: Davidous on June 28, 2019, 11:21:57 am
Hello,

I'm working with the chart you can find in the attachment.
I would like to get the screen coordinates of the 0 and 3 values of the y axis.
I've already tried YGraphToImage but the returned values were not what I was expecting.
Could someone please tell me how to do that correctly?
Title: Re: Coordinates of chart rectangle
Post by: wp on June 28, 2019, 01:05:02 pm
I've already tried YGraphToImage but the returned values were not what I was expecting.
That's what should work... Or are you using axis transformations? In this case the values displayed along the axis ("axis units") may be different from the transformed values used for plotting ("graph units"). You must have the axis transformation convert your value to graph units:
Code: Pascal  [Select][+][-]
  1. function GetChartImageY(Chart: TChart; y: Double): TPoint;
  2. begin
  3.   Result := Chart.LeftAxis.GetTransform.AxisToGraph(Chart.YGraphToImage(y));
  4. end;
Title: Re: Coordinates of chart rectangle
Post by: Davidous on June 28, 2019, 01:41:31 pm
Thank you wp! :)
TinyPortal © 2005-2018