Recent

Author Topic: TAChart different axes of left and right for different data series  (Read 11432 times)

grzegorz

  • New member
  • *
  • Posts: 7
Hi all  I'm a beginner Lazarus user and i have question:
Is it possible to do different axes left (temperature) and right (pressure) for different data series on the same graph (common horizontal time axis)?


Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TAChart different axes of left and right for different data series
« Reply #1 on: April 09, 2010, 09:27:36 am »
If you use the snapshot version: yes
Use DataSource property of each axis whose value you want to change

grzegorz

  • New member
  • *
  • Posts: 7
Re: TAChart different axes of left and right for different data series
« Reply #2 on: April 09, 2010, 10:08:34 am »
If you use the snapshot version:
yes
Quote
Use DataSource property of each axis whose value you want to change
but
unfortunately, I do not know how to do it.
It seems too complicated for me.
intuitively tried by a combination of AxisIndexy(tlineseries properties) with the corresponding axis  same way as in Delphi (lineSeries.VertAxis: = aRightAxis) but unfortunately does not work

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart different axes of left and right for different data series
« Reply #3 on: April 09, 2010, 11:34:05 am »
You may be interested in tachart/demo/axis/axisdemo project,
"Linear transform" page.

grzegorz

  • New member
  • *
  • Posts: 7
Re: TAChart different axes of left and right for different data series
« Reply #4 on: April 09, 2010, 12:15:09 pm »
You may be interested in tachart/demo/axis/axisdemo project,
"Linear transform" page.
in that example, all the vertical axes have the same minima maxima and scale.
I need to be independent  (pressure, temperature), conected only by vertical axis (time).

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart different axes of left and right for different data series
« Reply #5 on: April 10, 2010, 01:01:39 am »
Stragne. This example is specifically about representing two series with different scales
(temperature in degrees Celsius an Fahrenheit, but of course you are not limited to that).

BTW, please update you Lazarus to latest svn -- I have found a bug in the example a few days ago.

grzegorz

  • New member
  • *
  • Posts: 7
Re: TAChart different axes of left and right for different data series
« Reply #6 on: April 10, 2010, 03:33:21 pm »
Stragne. This example is specifically about representing two series with different scales
(temperature in degrees Celsius an Fahrenheit, but of course you are not limited to that).

BTW, please update you Lazarus to latest svn -- I have found a bug in the example a few days ago.
in that example, the axis of the left and right are not independent. The relationship between the axes describes ChartAxisTransformations.
thanks
sorry for my bad english

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart different axes of left and right for different data series
« Reply #7 on: April 11, 2010, 09:52:58 am »
You are right, automatic transformation are is on my TODO list.
For now, you may manually set linear transformation parameters.

ThB

  • Newbie
  • Posts: 3
Re: TAChart different axes of left and right for different data series
« Reply #8 on: December 31, 2010, 11:29:48 am »
Automatic axis scaling of LineSeries2 (on right axis) depending on LineSeries1 (left axis) can be done this way:

Code: [Select]
var tmp: Double;
...
If Chart1LineSeries1.Active then
  tmp := Chart1LineSeries1.GetYMax - Chart1LineSeries1.GetYMin
else
  tmp := 1;

If (Chart1LineSeries2.GetYMax <> Chart1LineSeries2.GetYMin) AND
   (Chart1LineSeries2.IsEmpty = false)
then begin
  LAT1.Scale := tmp / (Chart1LineSeries2.GetYMax - Chart1LineSeries2.GetYMin);
  LAT1.Offset := Chart1LineSeries1.GetYMin - LAT1.Scale * Chart1LineSeries2.GetYMin;
end;

I use it in my own project. :)



Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart different axes of left and right for different data series
« Reply #9 on: January 05, 2011, 05:04:31 pm »
In recent versions, you can also use TAutoScaleAxisTransform
(see "Auto scale" checkbox in the axisdemo).

 

TinyPortal © 2005-2018