
Is there a way to do word warp on the captions automatically? How can I make it so the caption always shows up?
Thank you,
Ed Dressel
Code: Select all
procedure TForm1.Chart1Resize(Sender: TObject);
var oneLineTitle: String;
titleHeight: Integer;
begin
oneLineTitle:=StringReplace(Chart1.Axes.Left.Title.Text, sLineBreak, '', [rfReplaceAll]);
Chart1.Canvas.AssignFont(Chart1.Axes.Left.Title.Font);
if Chart1.Height < Chart1.Canvas.TextWidth(oneLineTitle) then
Chart1.Axes.Left.Title.Text:=WrapText(oneLineTitle, sLineBreak, [' '], Chart1.Height div Chart1.Axes.Left.Title.Font.Size)
else
Chart1.Axes.Left.Title.Text:=oneLineTitle;
titleHeight:=Abs((Chart1.Axes.Left.Title.Text.CountChar(#13)+1)*Chart1.Axes.Left.Title.Font.Height);
Chart1.MarginLeft:=Round((titleHeight+5)*100/Chart1.Width);
end;
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
WrapLeftAxisTitle
) and move the code from the OnResize
event to it. Then, you only have to add a few parameters to it and call it both at OnResize
event and in your AssignChartToGraphic
method.![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |
Code: Select all
Series1.FillSampleValues(20);
ChartRect.Height
. Ie:
Code: Select all
procedure TForm1.WrapLeftAxisTitle(aChart: TChart; const aHeight: Integer);
var
lOneLineTitle: String;
lTitleHeight: Integer;
lTitle: TChartAxisTitle;
lHeight: Integer;
begin
Assert(aChart <> nil);
aChart.Draw;
lTitle := aChart.Axes.Left.Title;
lOneLineTitle := StringReplace(lTitle.Text, sLineBreak, ' ', [rfReplaceAll]);
lOneLineTitle := StringReplace(lOneLineTitle, ' ', ' ', [rfReplaceAll]);
aChart.Canvas.AssignFont(lTitle.Font);
lHeight:=aHeight;
if (aChart.Legend.Alignment=laTop) or (aChart.Legend.Alignment=laBottom) then
lHeight:=aChart.ChartRect.Height*aHeight div aChart.Height;
if lHeight < aChart.Canvas.TextWidth(lOneLineTitle) then
lTitle.Text := WrapText(lOneLineTitle, sLineBreak, [' '], lHeight div lTitle.Font.Size)
else
lTitle.Text := lOneLineTitle;
lTitleHeight:=Abs( (lTitle.Text.CountChar(#13) + 1) * lTitle.Font.Height);
aChart.MarginLeft := Round((lTitleHeight + 5) * 100 / aChart.Width);
end;
![]() | Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) |
![]() ![]() ![]() ![]() ![]() ![]() |
Please read our Bug Fixing Policy |