Recent

Author Topic: [SOLVED] TChart range  (Read 384 times)

engine32

  • New Member
  • *
  • Posts: 19
[SOLVED] TChart range
« on: November 16, 2022, 08:07:37 pm »
  Hi there,

  I am using TChart with two data series and two vertical axes (see picture).

  I would like to have different ranges for the two vertical axes, but I am not successful. I looks like there is some sort of auto range issue.

  On the left one I set
Code: Pascal  [Select][+][-]
  1.     frmMain.chart.LeftAxis.Range.Max := f64S1RangeMax;
  2.     frmMain.chart.LeftAxis.Marks.Range.Max := f64S1RangeMax;
  3.  
where f64S1RangeMax happen to be 250.

  On the right one I set:
Code: Pascal  [Select][+][-]
  1.     frmMain.chart.AxisList.Axes[2].Range.Max := 2048;
  2.     frmMain.chart.AxisList.Axes[2].Marks.Range.Max := 2048;
  3.  

  Because data on the right one is about 400, which is greater than the limit on the left side, the left axis gets the way it is in the picture.
 
  Thank you.
« Last Edit: November 17, 2022, 12:25:02 am by engine32 »

wp

  • Hero Member
  • *****
  • Posts: 10641
Re: TChart range
« Reply #1 on: November 16, 2022, 10:14:38 pm »
For two y axes with independent scales you need two AutoscaleAxistransformations (one for each axis); and for each series you must specify in the AxisIndexY property the index of the axis to be used for its vertical axis. Read the tutorial in https://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Dual_y_axis,_Legend.

I am attaching a small sample project with two independent axes. Study the changes in the object inspector since there is no code needed to achieve this. (OK - I could rewrite it with run-time code, but I am afraid that this is more confusing...)

engine32

  • New Member
  • *
  • Posts: 19
Re: [SOLVED] TChart range
« Reply #2 on: November 17, 2022, 12:25:56 am »
  It works nicely, Thank you.

 

TinyPortal © 2005-2018