Page 1 of 1

Setting the distance between axis and labels

Posted: Mon Aug 15, 2005 7:04 am
by 8443014
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?

Posted: Thu Aug 18, 2005 8:22 am
by Pep
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).