Axes Values Format of ffGeneral FloatFormat
Axes Values Format of ffGeneral FloatFormat
Is there a way to have axis labels format use fixed format for values within a range around 1 and use scientific format when outside the range. Similar to Delphi's FloatToStrF function specifying ffGeneral for its TFloatFormat type. This so label values far from 1 (for example 34596783263.93457 or 0.000000008345345234) would take less space on the chart by using the Exponent to indicate how large the value is.
Hi, Steve.
Yes, it can be done, but if will require some code. I'd first display all axis labels in standard (float) format and then in chart OnGetAxisLabel event reformat labels outside specificed range. Something like this (just an example to give you basic idea):
Yes, it can be done, but if will require some code. I'd first display all axis labels in standard (float) format and then in chart OnGetAxisLabel event reformat labels outside specificed range. Something like this (just an example to give you basic idea):
Code: Select all
procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var tmp: double;
begin
if Sender = Chart1.Axes.Left then
begin
// if you use thousand separator, you'll have to remove it prior to calling StrToFloat
tmp := StrToFloat(LabelText);
if Abs(tmp)>1 then LabelText := FormatFloat('0.0E+00',tmp);
end;
end;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com