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 - New property to automatically wrap text in axis title
Summary: New property to automatically wrap text in axis title
Status: CONFIRMED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Axis (show other bugs)
Version: 30.200525
Hardware: PC Windows
: --- enhancement
Target Milestone: ---
Assignee: Steema Issue Manager
URL: https://www.steema.com/support/viewto...
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-18 01:37 EDT by yeray alonso
Modified: 2020-09-18 12:56 EDT (History)
2 users (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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;