aligning the chart title

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Trusler
Newbie
Newbie
Posts: 3
Joined: Fri Nov 15, 2002 12:00 am

aligning the chart title

Post by Trusler » Mon Jan 23, 2012 5:02 am

I'd like to have the chart title left-aligned to the y-axis. Selecting Alignment=left aligns the title with the margin of the chart, so it starts over the y-axis title, rather than over the y axis itself.
title_align.png
title_align.png (20.44 KiB) Viewed 2502 times
Custom positioning isn't quite what my customer is looking for, since using an absolute value is probably slightly off in some instances. And in any case, turning on custom positioning of the title expands the border of the graph such that the chart title appears on the graph itself, rather than above it (which is not desired).

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: aligning the chart title

Post by Yeray » Mon Jan 23, 2012 3:17 pm

Hi Trusler,

What about a TAnnotation tool? The following seems to give a quite good result for me here:

Code: Select all

  with Chart1.Tools.Add(TAnnotationTool) as TAnnotationTool do
  begin
    Chart1.Title.Visible:=false;
    Chart1.MarginTop:=25;

    Text:='TChart';
    Shape.Font.Color:=clBlue;
    Shape.Transparent:=true;
    Shape.Font.Size:=8;
    Shape.Font.Name:='Verdana';
    Left:=Chart1.Axes.Left.PosAxis;
    Top:=Chart1.Axes.Left.IStartPos - 20;
  end;
And you could call the following at your OnScroll, OnZoom and OnUndoZoom to force the text to be positioned on place even when the labels make the margin on the axis to be changed.

Code: Select all

  Chart1.Draw;
  if (Chart1.Tools.Count>0) then
    (Chart1.Tools[0] as TAnnotationTool).Left:=Chart1.Axes.Left.PosAxis;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply