multiple y-axes, again lazarus / 55-TAChart ---------------------------------------------------------------------- mtanner · 2017-03-21 21:53 I am returning to this topic again after trying to understand it some while ago.  What I am trying to do is quite straightfoward. I have a chart with two series, assume they are line series. One series uses the left axis, the other series uses the right axis. I want to control the range plotted on each axis. For a single Y axis I can easily do this using MyChart.Extent, YMin,YMax, UseYMin,UseYMax. I must admit that trying to make this work with two y axes just left me totally baffled, despite some lengthy replies to the posts I submitted then. I gave up through lack of time and redesigned my application to use charts with just a single y-axis. Now I have another application that could really benefit from separate y-axes. Is it possible for someone to just give me the code to do what I need? The code snippets supplied before, and the info in the various tutorials, does not actually supply complete code for what I am sure must be a common requirement, and I suspect I'm not the only one to have difficulty with this. Once I've got something that works, then maybe I will be better able to understand why it works. But the pressures of development mean that I need to just get things working first. For single y-axis I use: With MyChart.Extent do begin   set YMin,YMax UseYMin, UseYMax in an obvious way end; ---------------------------------------------------------------------- wp · 2017-03-21 22:43 No, Chart.Extent is not good for multiple axes because it works on the invisible coordinate system shared by all axes ("graph coordinates"). Instead, use the Range property of each axis. It has a Min and Max value to define its limits, as well as boolean UseMin and UseMax properties to activate them. Min and Max are specified in "graph units" -- these are the units in which you add the data, so, nothing to worry about. You may also want to set axis.Marks.AtDataOnly to true to draw axis labels only between this min and max, and also to set axis.Title.PositionOnMarks to true to center the title between min and max. As for the steps required to create multiple axes see the tutorials ht tp://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Dual_y_axis,_Legend and http://wiki.lazarus.freepascal.org/TAChart_Tutorial:_Multiple_Pane s_in_one_Chart, and the demos in the folders lazarus/components/tachart/demo/panes, panes-2 and pane-3. In Lazarus trunk there is also a runtime-only demo in the folder runtime/dualaxes of the tachart demo directory. ---------------------------------------------------------------------- mtanner · 2017-03-22 12:52 Thanks for that. I will try and get this to work. Problem is I fall at the first hurdle. Just using a single y-axis chart I try to control the x range with the following code. With MyChart.BottomAxis.Range do begin    Min:=;    Max:=;    UseMin:=true;    UseMax:=true; end; bit this has no effect, TAGraph just uses the maximum x range for the data submitted. ---------------------------------------------------------------------- wp · 2017-03-22 14:34 Setting the axis Range is one of the last steps to apply. And I guess it will not work for single-axis charts at all. Please read the tutorial, I don't want to repeat details: You must add TChartAxisTransformations and an AutoScaleAxisTransform for each of the dual axes. And don't forget to assign the AxisIndex of the series to indicate to which axis it belongs. ---------------------------------------------------------------------- mtanner · 2017-03-23 06:39 I will go and do my homework. TAGraph does seem very good, but has some design concepts rather different to TeeChart, so anything other tham straightforward charts requires some investment in learning. It took me a while to get my head around stacked bar charts, but the results are excellent. ---------------------------------------------------------------------- mtanner · 2017-03-24 10:28 Well I've now got dual y-axes working ok at least as far as I need, after following the tutorial. The multiple axes mechanism seems a bit elaborate for what I am doing, because it's obviously a very flexible facility of which I am just scratching the surface. One small confusing point. I can control the left/right y-axes fine using Range, after setting up the transforms. But when I try and use the same technique to control the range of the (single) x-axis it doesn't work. So I went back to using Extent just for the x-axis and that works ok. ---------------------------------------------------------------------- wp · 2017-03-24 11:56 I think this "equations" are correct (not tested)   single axis = use Chart.Extent   axis with transformations = use Axis.Range You probably can add another ChartAxisTransformation and AutoScaleAxisTransform, and assign it to the bottom axis of the chart -- and don't forget to set the AxisIndexX of the series properly. Then there is a transformation for the x axis, and range should work for it as well.