Recent

Author Topic: Coordinates of chart rectangle  (Read 235 times)

Davidous

  • Jr. Member
  • **
  • Posts: 67
Coordinates of chart rectangle
« 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?

wp

  • Hero Member
  • *****
  • Posts: 6233
Re: Coordinates of chart rectangle
« Reply #1 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;
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Davidous

  • Jr. Member
  • **
  • Posts: 67
Re: Coordinates of chart rectangle
« Reply #2 on: June 28, 2019, 01:41:31 pm »
Thank you wp! :)