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?
Setting the distance between axis and labels
-
- Advanced
- Posts: 103
- Joined: Tue Mar 02, 2004 5:00 am
- Location: Bad Wurzach
- Contact:
Hi,
to solve this you could use similar code to the following :
Which will assign to the labelSize the width of the max value (round value).
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;
Pep Jorge
http://support.steema.com
http://support.steema.com