Long time ago I posted a question regarding on how I can align the chart Title caption relative to left and right axis area. Apparently I have the same issue with 2010 version.... Is it possible to do so as it looks really ugly

Regards
Code: Select all
uses series;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
Chart1.Title.Left:=Chart1.Axes.Left.PosAxis;
Chart1.Title.Top:=10;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Chart1.View3D:=false;
Chart1.MarginTop:=8;
Chart1.Title.CustomPosition:=true;
Chart1.Title.Text.Text:='My custom title aligned';
Chart1.Title.Font.Size:=10;
Chart1.Title.Font.Color:=clRed;
with Chart1.AddSeries(TPointSeries) do FillSampleValues();
Chart1.Draw;
end;
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var l, r, w, x,y: integer;
begin
l := Chart1.Axes.Bottom.IStartPos;
r := Chart1.Axes.Bottom.IEndPos;
chart1.Canvas.Font.Assign(chart1.Title.Font);
chart1.Canvas.Font.Color := clBlue;
w := Chart1.Canvas.TextWidth(chart1.Title.Caption);
chart1.Title.Left := round(l + (r-l)*0.50 - w*0.50);
chart1.Canvas.TextOut(round(l + (r-l)*0.50 - w*0.50),8,chart1.Title.Caption);
Chart1.Title.Top:=10;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Chart1.View3D:=false;
Chart1.MarginTop:=8;
Chart1.Title.CustomPosition:=true;
Chart1.Title.Text.Text:='My custom title aligned';
Chart1.Title.Font.Size:=10;
Chart1.Title.Font.Color:=clRed;
with Chart1.AddSeries(TPointSeries) do FillSampleValues();
chart1.Series[0].ShowInLegend := false;
Chart1.Draw;
end;
Code: Select all
uses Series;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var l, r, w, x, y, pos: integer;
begin
l := Chart1.Axes.Bottom.IStartPos;
r := Chart1.Axes.Bottom.IEndPos;
w := Chart1.Canvas.TextWidth(Chart1.Title.Caption);
pos:=round(l + (r-l)*0.50 - w*0.50);
Chart1.Title.CustomPosition:=true;
Chart1.Title.Left:=pos;
Chart1.Title.Top:=10;
Chart1.Canvas.Font.Assign(Chart1.Title.Font);
Chart1.Canvas.Font.Color:=clBlue;
Chart1.Canvas.TextOut(pos,8,Chart1.Title.Caption);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Chart1.View3D:=false;
Chart1.MarginTop:=8;
Chart1.Title.Text.Text:='My custom title aligned';
Chart1.Title.Font.Size:=10;
Chart1.Title.Font.Color:=clRed;
Chart1.Title.Transparent:=False;
Chart1.AddSeries(TPointSeries.Create(Self)).FillSampleValues();
Chart1[0].ShowInLegend:=false;
Chart1.Draw;
end;
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |