TChartAxis.LabelsMultiLine
TChartAxis
property LabelsMultiLine: Boolean;
Unit
TeEngine
Description
Default = False
Enables multiline Axis labels.
When True, spaces in point Labels or in Axis TChartAxis.DateTimeFormat or TChartAxis.AxisValuesFormat are used to break the label in more than one line of text).
When False, labels with #13 characters are break in lines.
Example
Series1.Add( 1234, 'Hello'+#13+'World', clGreen );
Example for DateTime labels
The following will show the bottom axis labels in two lines of text, one
showing the month and day, and the second line showing the year:
Feb-28 Mar-1 ..
1998 1998 ..
Series1.AddXY( EncodeDate( 1998,2,28 ), 100, '', clTeeColor );
Series1.AddXY( EncodeDate( 1998,3,1 ), 200, '', clTeeColor );
Series1.AddXY( EncodeDate( 1998,3,2 ), 150, '', clTeeColor );
Series1.XValues.DateTime := True;
Chart1.BottomAxis.DateTimeFormat := 'mm/dd hh:mm'; { <-- space }
If you set the LabelsMultiLine property to True, then the axis will automatically split labels in lines where it finds an space.
Chart1.BottomAxis.MultiLine:=True;
Will use the formatting divided in two:
'mm/dd' for the first line
'hh:mm' for the second line
At run-time you can always split the label into lines programatically using the TCustomAxisPanel.OnGetAxisLabel event:
procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
TeeSplitInLines(LabelText,' ');
end;