Page 1 of 1

Labels for horizontal series

Posted: Fri Mar 06, 2020 12:26 am
by 16587426
Attached is a simple demo where the horizontal series caption has two lines. Works fine.

My customer wants two modifications that I do not know how to do:

1) They would like the left axis labels to be right-aligned.

2) They would the second line (the value) bolded.

Are either of those possible?

Thank you,

Ed Dressel

Re: Labels for horizontal series

Posted: Fri Mar 06, 2020 11:21 am
by yeray
Hello,

Is this what you are trying to achieve?
Project1_2020-03-06_11-57-48.png
Project1_2020-03-06_11-57-48.png (9.62 KiB) Viewed 2649 times
This is the code I used to draw the above:

Code: Select all

constructor TForm1.Create(aOwner: TComponent);
var
  lValue: currency;
  I: Integer;
  lCaption: string;
begin
  inherited;
  for I := 1 to 5 do begin
    lValue := Trunc(Random(1000));
    lCaption := Format('Item #%d'+sLineBreak+'<b>%.0m</b>', [I, lValue]);
    Series1.AddBar(lValue, lCaption, clTeeColor);
  end;

  Chart1.Axes.Left.LabelsFormat.TextAlignment:=taRightJustify;
  Chart1.Axes.Left.LabelsFormat.TextFormat:=ttfHtml;
end;
As you can see I'm using Html format to customize part of the labels. Note there was a bug I've just fixed: #2294.

Re: Labels for horizontal series

Posted: Thu Mar 12, 2020 8:38 pm
by 16587426
That's cool... but I don't know how you did that--attached is my demo that neither right aligns the values not bolds the items.

What am I doing wrong?

Ed Dressel

Re: Labels for horizontal series

Posted: Fri Mar 13, 2020 11:41 am
by yeray
Hello,

You missed this part in your code:

Code: Select all

  Chart1.Axes.Left.LabelsFormat.TextAlignment:=taRightJustify;
  Chart1.Axes.Left.LabelsFormat.TextFormat:=ttfHtml;

Re: Labels for horizontal series

Posted: Fri Mar 13, 2020 5:12 pm
by 16587426
Perfect. Thank you.