When to set Axis.LabelsSize

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
fabnav
Newbie
Newbie
Posts: 17
Joined: Thu Sep 30, 2004 4:00 am

When to set Axis.LabelsSize

Post by fabnav » Thu Mar 15, 2007 2:51 pm

Hi,

Sometimes I see a problem with the axis labels overlapping the axis title when I set Axis.LabelsSize := 0. The solution is to set Axis.LabelsSize to another value. The problem is that I don't know what that value should be until I look at all of the values in the GetAxisLabel event handler.

My problem is that setting Axis.LabelsSize at that point seems to be too late to have any affect.

How do I get this to work properly?

Regards,

Bill

fabnav
Newbie
Newbie
Posts: 17
Joined: Thu Sep 30, 2004 4:00 am

Post by fabnav » Thu Mar 15, 2007 3:11 pm

Another way to demonstrate this problem is to set Axis.LabelsSize := 0 and then modify the LabelText value from within the GetAxisLabel event handler. If you append some characters to the LabelText value, there will definately be a big overlap issue with the axis title.

It seems to me that currently the space alloted to the axis labels is determined "before" the GetAxisLabel event handler is called. I think it needs to be determined "after" the GetAxisLabel event handler is called.

Bill

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 16, 2007 5:09 pm

Hi Bill,

It works fine here using something like the code below. In the OnAfterDraw event LabelsSize is assigned to a value related to MaxLabelsWidth property. To force this being applied to the chart I called TChart's Draw method in the form's OnCreate event.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 100 do
    Series1.Add(i/10);

  Chart1.Draw;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  Chart1.Axes.Left.LabelsSize := Chart1.Axes.Left.MaxLabelsWidth*2;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

fabnav
Newbie
Newbie
Posts: 17
Joined: Thu Sep 30, 2004 4:00 am

Post by fabnav » Mon Mar 19, 2007 2:01 pm

Hi,

It is working for me now using the AfterDraw event. I needed to add a call to Chart.Draw. It wasn't working when I was just calling Chart.Show.

Regards,

Bill

Post Reply