Page 1 of 1

the title of left axis is overlapping the labels

Posted: Thu Feb 09, 2006 3:39 pm
by 9339785
Hi,
I have a problem with the title of left axis. Sometimes the title is overlapping the labels, as you can see on this screenshoot :

[img]
http://cjoint.com/data/cjqDEF8DHg.htm
[/img]

I don't understand why .... as I set TChartAxis.TitleSize = 0 this must not happen.
Any solutions for this problem ?

Thanks
Franck

Posted: Thu Feb 09, 2006 4:18 pm
by narcis
Hi Franck,

Yes, this is a known problem. In the meantime, you can solve that by setting the axis labels size:

Code: Select all

  Chart1.Axes.Left.LabelsSize:=30;

Posted: Fri Feb 10, 2006 9:03 am
by 9339785
yes of course I could manage it myself .... but as it's a bug of the graph, I really hope that it will be corrected in the next version.

bye
Franck

Posted: Fri Feb 10, 2006 10:04 am
by narcis
Hi Franck,

Yes, as I told you, it's a known bug and it is already on our defect list to be fixed for future releases.

Posted: Mon Feb 20, 2006 6:56 pm
by 9339348
Hi,

I have the same problem, and setting the LabelsSize to a constant isn't a workaround to the bug. There needs to be a way to calculate how much space is used, and then add some to that.

Is there a way to determine the amount of space that is allocated to the axis labels so that we can add a little padding?

Regards,

Bill

Posted: Tue Feb 21, 2006 8:38 am
by narcis
Hi Bill,

Yes, you can do something like this:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
    Chart1[i].FillSampleValues();

  Chart1.Axes.Left.Title.Caption:='My left axis title';
  Chart1.Draw;
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  if Sender=Chart1.Axes.Left then
    if (StrLen(PChar(LabelText))*4)>Chart1.Axes.Left.LabelsSize then
      Chart1.Axes.Left.LabelsSize:=StrLen(PChar(LabelText))*4;
end;

Posted: Tue Feb 21, 2006 3:37 pm
by 9339348
It looks like you are assuming four pixels per character, but that won't always be the case.

In addition, using this event will be slow when there are a large number of points. It would probably work if only the labels being displayed triggered the event, but that isn't the case.

Bill

Posted: Tue Feb 21, 2006 4:39 pm
by narcis
Hi Bill,
It looks like you are assuming four pixels per character, but that won't always be the case.
You can make this constant dependant of the font size or whatever you consider can affect that. It was just an idea to try to give a better workaround for the issue.
In addition, using this event will be slow when there are a large number of points. It would probably work if only the labels being displayed triggered the event, but that isn't the case.
This event is actually fired for all axes labels displayed but the code will only be executed for the left axis labels.