Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 2369

Summary: New property to automatically wrap text in axis title
Product: VCL TeeChart Reporter: yeray alonso <yeray>
Component: AxisAssignee: Steema Issue Manager <issuemanager>
Status: CONFIRMED ---    
Severity: enhancement CC: dressel, yeray
Priority: ---    
Version: 30.200525   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
URL: https://www.steema.com/support/viewtopic.php?p=77492#p77492
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description yeray alonso 2020-09-18 01:37:15 EDT
This can be done manually but a property to automatically do it would be helpful.

Note in the code example I'm also modifying the margin to leave space for the new lines.

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;