Recent

Author Topic: Does TAChart have independent vertical axis?  (Read 6104 times)

AlZuur

  • New Member
  • *
  • Posts: 11
Does TAChart have independent vertical axis?
« on: November 20, 2009, 03:26:28 pm »
In my application I use TAChart. With the latest additions and changes to the component, the component and my application work good.

The next functionality I would like to build into my application must show two different values in the same graph. My application is a graphing tool for my weather station. {Why not use ...? Because I don't like gimmicks.} The weather station measures temperatures, windspeed, humidity, air pressure. My application does some additional calculations and shows the values.
To analyze the weather, the user must be able to see different values in one graph, for example temperature and humidity.

As far as I can see this is not possible in TAChart, but I may be wrong. As a understand TAChart, all series are shown as if they are in the same data range. The vertical axis thus can be used for different units of the same values, but not for different values in the same graph. The result is that if I have a series of air pressure (values between 28 and 32) and a series of temperature (values in summer between 60 and 100) then the air pressure is shown to the bottom of the graph and the temperature to the top of the graph. I would like to have air pressure and temperature each use the whole height of the graph, this would allow to see more detail in the different values. The left axis would show the range for temperature and the right axis would show the range for air pressure.

The way I see this accomplished is that I can assign a vertical axis to a data serie. The axis would then scale the values, while currently the chart does all the scaling. The groundwork is already there: the ICoordTransformer could be implemented by the axis and an extra property (e.g. ScalingAxis) could be given to the series. Then if the scaling axis property is set, the axis does the scaling; if not then the chart does the scaling. As far as I can see this would only apply to line series and bar series.

I would love to develop this and contribute this functionality for the component, but I want to make sure the functionality I want cannot be accomplished in another way.
Is there a way to show two different ranges of values independently layed out in a TAChart line graph?

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Does TAChart have independent vertical axis?
« Reply #1 on: November 22, 2009, 03:36:31 pm »
For you future reference: Lazarus mailing list is the preferred place for discussions related to the Lazarus development.

Quote
The way I see this accomplished is that I can assign a vertical axis to a data serie. The axis would then scale the values, while currently the chart does all the scaling.
Your are mostly correct in your analysis.
There is already an issue for that (http://bugs.freepascal.org/view.php?id=13832).

Said issue contains a patch which tries to implement multi-axis support.
I have applied only parts of this patch, since the implementation is, in mu opinion,
not quite general enough.
In particular, it would not allow user to control relative axis ranges.
Still, you may take a look -- maybe this will be enough for you until the
proper support arrives.

Since apparently multi-axis charts is highly requested feature, I am planning
to implement it as soon as I have free time to hack on Lazarus.
The plan is as follows:
1) Currently, TChart works with two coordinate systems: Graph (aka world) coordinates
and Image (aka screen) coordinates. I plan to add third, Axis (or data) coordinates.
2) Axis->Graph conversion should be handled by axis according to its conversion mode,
Graph->Image conversion should be handled by chart according to its zoom factor and viewport offset.
3) So the first task is to abstract out all coordinate transformations into
a pair of functions -- AxisToGraph and GraphToAxis, similar to
existing GraphToImage and ImageToGraph ones. Note that both direct and inverse transformation should be handled.

If you want to help, the above is the (first) patch I would like to receive.
After that, we may proceed further.
Patches should be submitted into the Mantis bug tracker.