Setting the distance between axis and labels

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Thomas Klingler
Advanced
Posts: 103
Joined: Tue Mar 02, 2004 5:00 am
Location: Bad Wurzach
Contact:

Setting the distance between axis and labels

Post by Thomas Klingler » Mon Aug 15, 2005 7:04 am

Hello everyone.
I know this subject was discussed lots of times in the support section. Still there is a question that i hope someone will answer. As far as i know, LabelsSize property of TChartAxis is used for setting the distance between axis and labels. What if there is a need to set the distance depending on current axis labels, which are likely to change dynamically? This code was used:

seriesAxis_->LabelsSize = seriesAxis_->LabelWidth(seriesAxis_->Maximum) + 5;
samplesAxis_->LabelsSize = samplesAxis_->LabelWidth(samplesAxis_->Maximum) + 5;

But, the Maximum property of the TChartAxis returns the maximum value, even if it's invisible. For instance, the topmost label is "10", and Maximum property is equal to 10.25. I've tried setting the Automatic property to true/false, but it does not influence much. Could someone help me?

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Aug 18, 2005 8:22 am

Hi,

to solve this you could use similar code to the following :

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
var w : integer;
begin
w:= Chart1.Canvas.TextWidth(floattostr(Round(Chart1.Axes.Left.Maximum)));
Chart1.Axes.Left.LabelsSize := w;
end;
Which will assign to the labelSize the width of the max value (round value).

Post Reply