Page 1 of 1

When to set Axis.LabelsSize

Posted: Thu Mar 15, 2007 2:51 pm
by 9234349
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

Posted: Thu Mar 15, 2007 3:11 pm
by 9234349
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

Posted: Fri Mar 16, 2007 5:09 pm
by narcis
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;

Posted: Mon Mar 19, 2007 2:01 pm
by 9234349
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