Recent

Author Topic: TChartAxis.SetMinMax  (Read 1561 times)

antekg

  • New member
  • *
  • Posts: 6
TChartAxis.SetMinMax
« on: September 23, 2018, 01:58:16 pm »
Hello,
I'm migrating from Delphi.
In Lazarus, TChartAxis does not have the SetMinMax method. In the TAChartTeeChart unit, I completed TChartAxisTeeChart class helper with the SetMinMax (Const AMin, AMax: Double); How to write this procedure refering to TChartAxis?

wp

  • Hero Member
  • *****
  • Posts: 6234
Re: TChartAxis.SetMinMax
« Reply #1 on: September 23, 2018, 05:02:32 pm »
I must confess that I am not so well-experienced with TeeChart to understand what exactly TChartAxis.SetMaxMin does, in particular when several axes are overlayed.

In the simplest case of standard axes you can adapt the Chart.Extent to force fixed axis limits (see also http://wiki.lazarus.freepascal.org/TAChart_Runtime_FAQ#Fixed_axis_limits):
Code: Pascal  [Select]
  1.   Chart1.Extent.XMax := 1000;
  2.   Chart1.Extent.XMin := -1000;
  3.   Chart1.Extent.UseXMin := true;
  4.   Chart1.Extent.UseXMax := true;
  5.   // Similarly for y axis
  6.  
Only when no axis transformations are involved then the values passed to .XMax, .XMin, .YMax, .YMin are in the units of the data ("axis units"). Otherwise the transformed values ("graph units") must be used. Suppose you have a (decadic) logarithmic axis, and you want to freeze the x axis limits at 1 to 1000, then you must specify .XMin to be 0 (because it is the log of 1) and .XMax to be 3 (because it is the log of 1000).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10