Page 1 of 1

Align Left and Custom Axis titles when at angle 90

Posted: Mon Mar 15, 2010 5:05 pm
by 10049005
When Left axis and Left Custom Axis titles are at a 90 degree angle, how is it possible to align them so that they line up. (D2010, TeeChart 8.06). It appears that their offset from the panel is determined by each Axis' max label width. Is there a way to get all of the axes to calculate offset based on ALL of the labels involved?

Thanks,

Re: Align Left and Custom Axis titles when at angle 90

Posted: Tue Mar 16, 2010 12:19 pm
by yeray
Hi DanKerlee,

I'm afraid that the title position is calculated internally and, as you've seen, relative to its own MaxLabelsWidth. What you could do is to hide the titles and draw them using custom drawing techniques:

Code: Select all

uses series, TeCanvas;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  Chart1.View3D:=false;

  for i:=0 to 1 do with Chart1.AddSeries(TFastLineSeries.Create(self)) do
  begin
    Chart1[i].Add(Random*100+i*10000);
    for j:=0 to 24 do Chart1[i].Add(Chart1[i].YValue[Chart1[i].Count-1] + Random*10 - 5);
  end;

  Chart1.CustomAxes.Add;
  Chart1[1].CustomVertAxis:=Chart1.CustomAxes[0];

  Chart1.Axes.Left.EndPosition:=50;
  Chart1.CustomAxes[0].StartPosition:=50;
  Chart1.Axes.Left.Title.Caption:='Left Axis';
  Chart1.CustomAxes[0].Title.Caption:='Custom Axis';
{  Chart1.Axes.Left.Title.Angle:=90;
  Chart1.CustomAxes[0].Title.Angle:=90;}
  Chart1.Axes.Left.Title.Visible:=false;
  Chart1.CustomAxes[0].Title.Visible:=false;

  Chart1.MarginLeft:=5;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i: Integer;
    tmp1, tmp2: Double;
begin
  for i:=0 to Chart1.Axes.Count-1 do
    with Chart1.Axes[i] do
    if not Horizontal then
    begin
      tmp1:=(CalcPosValue(Minimum+(Maximum-Minimum)/2));
      tmp2:=Form1.Canvas.TextWidth(Title.Caption)/2;
      Chart1.Canvas.RotateLabel(10,Round(tmp1+tmp2),Title.Caption,90);
    end;
end;