Recent

Author Topic: How to align 45 degree bar chart labels to end at stick mark?  (Read 11064 times)

jacmoe

  • Full Member
  • ***
  • Posts: 249
    • Jacmoe's Cyber SoapBox
Re: How to align 45 degree bar chart labels to end at stick mark?
« Reply #15 on: February 24, 2017, 01:48:41 am »
That really looks great!
And truly useful - awesome stuff  :D
more signal - less noise

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: How to align 45 degree bar chart labels to end at stick mark?
« Reply #16 on: February 24, 2017, 09:36:59 am »
There should be no empty space below or above the text.
I tested with this code (form + paintbox, paintbox.Font.Size := 32), and it results in the attached screenshot (Win 10):
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DrawText(x, y: Integer; AText: String);
  2. var
  3.   sz: TSize;
  4. begin
  5.   with Paintbox1.Canvas do begin
  6.     Font.Assign(Paintbox1.Font);
  7.     sz := TextExtent(AText);
  8.     Brush.Color := clWhite;
  9.     Pen.Color := clBlack;
  10.     Rectangle(x, y, x + sz.cx, y + sz.cy);
  11.     Brush.Style := bsClear;
  12.     TextOut(x, y, AText);
  13.     Pen.Color := clRed;
  14.     Line(x, y + sz.cy div 2, x + sz.cx, y + sz.cy div 2);
  15.   end;
  16. end;
  17.  
  18. procedure TForm1.PaintBox1Paint(Sender: TObject);
  19. begin
  20.   DrawText(10, 10, 'ABC');
  21.   DrawText(110, 10, 'abc');
  22.   DrawText(210, 10, 'gj');
  23. end;

There IS some white space above and below the text. It is distributed more or less evenly at the top and bottom of the text if the text contains upper-case characters, In case of lower-case characters, however, the center of the bounding box (red line) is markably shifted from where it should appear visually.

 

TinyPortal © 2005-2018