Recent

Author Topic: Pixelvalues from TAutoScaleAxisTransform  (Read 1495 times)

kapibara

  • Hero Member
  • *****
  • Posts: 656
Pixelvalues from TAutoScaleAxisTransform
« on: December 15, 2023, 08:55:45 am »
Is there a way to convert TAutoScaleAxisTransform's MaxValue and MinValue to pixel values? (I want to move a Tpanel by it's Top property in relation to that.)

I read the wiki entry "How to find the pixel coordinates of the point of the y axis?" but I think that example uses Y values from series data which in this case doesn't exist yet.
Lazarus trunk / fpc 3.2.2 / Kubuntu 24.04 - 64 bit

wp

  • Hero Member
  • *****
  • Posts: 13424
Re: Pixelvalues from TAutoScaleAxisTransform
« Reply #1 on: December 15, 2023, 11:12:44 am »
Since TAutoScaleAxisTransform's MaxValue and MinValue are numbers in graph units, I guess that the chart's GraphToImage functions should do what you want.

Code: Pascal  [Select][+][-]
  1. type
  2.   TChart = class(....)
  3.   ...
  4.   public
  5.     ...
  6.     function GraphToImage(const AGraphPoint: TDoublePoint): TPoint;
  7.     function ImageToGraph(const APoint: TPoint): TDoublePoint;
  8.     function XGraphToImage(AX: Double): Integer; inline;
  9.     function XImageToGraph(AX: Integer): Double; inline;
  10.     function YGraphToImage(AY: Double): Integer; inline;
  11.     function YImageToGraph(AY: Integer): Double; inline;
  12.     ...
  13.   end;

kapibara

  • Hero Member
  • *****
  • Posts: 656
Re: Pixelvalues from TAutoScaleAxisTransform
« Reply #2 on: December 16, 2023, 07:30:46 am »
GraphToImage did the trick. With the old project it returned incorrect values so I thought it was the wrong function to use. Then I made a new test project and it works fine.

The old project must have something misconfigured. I'll look over chart settings, axises etc. Its of course too much to ask where you think the culprit is likely to be, but who knows. :-)
Lazarus trunk / fpc 3.2.2 / Kubuntu 24.04 - 64 bit

wp

  • Hero Member
  • *****
  • Posts: 13424
Re: Pixelvalues from TAutoScaleAxisTransform
« Reply #3 on: December 16, 2023, 12:31:13 pm »
I am not aware of any recent changes related to the coordinate calculation.

 

TinyPortal © 2005-2018