Page 1 of 1

word wrap on axis titles?

Posted: Mon Jul 21, 2008 4:36 pm
by 10546565
I have to have multiple sizes for various charts--is there any way to have a word wrap option for the axis titles? ( I did not see anything like this).

Thank you,
Ed Dressel

Posted: Tue Jul 22, 2008 8:29 am
by yeray
Hi Ed,

I'm afraid there is not an automatic option to do that. However, you could calculate the length of the title string in pixels, compare with the axis size, and add your "end of line" manually. Here is how your method could start:

Code: Select all

procedure TForm1.WordWrap;
begin
  //Bottom Axis
  Canvas.Font.Size := Chart1.Axes.Bottom.Title.Font.Size;
  TitleWidth := Canvas.TextWidth(Chart1.Axes.Bottom.Title.Caption);
  AxisWidth := Chart1.Axes.Bottom.IEndPos -   Chart1.Axes.Bottom.IStartPos;

  if (AxisWidth < TitleWidth) then
  begin
  //... Find a substring in the title shorter than AxisWidth and add the chars #13#10 to do the line jump
  end;

  //Next Axis
  //...
end;