Page 1 of 1

LabelText := '' stops further labels from displaying

Posted: Wed May 25, 2005 7:32 pm
by 9333098
Setting LabelText := '' in a chart's OnGetAxisLabel event causes axis labels to not be displayed in some cases. If this is done as a result of checking whether the label is a floating point number, then axis labels are not shown. For example :

for i := 0 to 5 do series1.AddXY(i,random(10));

and then in OnGetAxisLabel event saying either :

if trunc(strtofloat(LabelText)) <> strtofloat(LabelText) then LabelText := ''

or :

if pos('.', labeltext) <> 0 then LabelText := '';

causes the integer labels 2,3,4 to not be displayed. The OnGetAxisLabel event is not even fired for them. This appears to be due to the initial lables for the charts being floating point numbers (5.03 and -0.03) as seen by adding the LabelText to a memo in this event. Setting LabelText to a space character instead of an empty string avoids this problem.

Posted: Fri May 27, 2005 10:22 am
by narcis
Hi Steve,

If you don't want to display decimal values at axes labels you could use:

Code: Select all

  Chart1.Axes.Left.AxisValuesFormat:='##';

Posted: Fri May 27, 2005 1:20 pm
by 9333098
Narcis,

This would show 2.5 as 2. Then, the axis value of 2.0 also appears as 2 and so two axis labels with the same text appear. I do not want any label shown for decimal labels, but I do want the tick mark. Things are working by specifying a space character instead of empty string.

Steve

Posted: Mon May 30, 2005 10:28 am
by narcis
Hi Steve,

Yes, you are right. I've been able to reproduce this and already added it to our deffect list to be fixed for future releases.