Hi Narcís
Thank you for your fast and excellent support.
The key to my solution was the article:
http://www.teechart.net/support/viewtopic.php?t=5923
Especially the PlaceAxes procedure was useful.
Since my App hasn't got a linear relation between series and CustomAxes, and since I don't quite get the point of having two constants (you have to tune them in parallel anyway), I made a few improvements.
Here is my version (in case anyone is interested):
Code: Select all
procedure TfrmGraph.PlaceAxes(nSeries: Integer=0; NextXLeft: Integer=0; NextXRight: Integer=0; MargLeft: Integer=0; MargRight: Integer=0);
const
extraPos = 18;
minMarginLeft = 15;
minMarginRight = 15;
var
ca : TChartAxis;
begin
ca := Chart.Series[nSeries].GetVertAxis;
if Chart[nSeries].Active and Assigned(ca) and ca.Visible then
begin
if ca.OtherSide then
begin
ca.PositionPercent := NextXRight;
NextXRight := NextXRight - ca.MaxLabelsWidth - ca.TickLength - extraPos;
MargRight := MargRight + ca.MaxLabelsWidth + ca.TickLength + extraPos;
end
else
begin
ca.PositionPercent := NextXLeft;
NextXLeft := NextXLeft - ca.MaxLabelsWidth - ca.TickLength - extraPos;
MargLeft := MargLeft + ca.MaxLabelsWidth + ca.TickLength + extraPos;
end;
end;
Chart.MarginLeft := Max(minMarginLeft,MargLeft);
Chart.MarginRight := Max(minMarginRight, MargRight);
nSeries := nSeries + 1;
if nSeries <= Chart.SeriesCount - 1 then
begin
PlaceAxes(nSeries, NextXLeft, NextXRight, MargLeft, MargRight);
end;
end;