LabelText := '' stops further labels from displaying
Posted: Wed May 25, 2005 7:32 pm
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.
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.