Page 1 of 1

Adjust positions of marks in a TPointSeries?

Posted: Sat Jul 15, 2017 5:03 pm
by 16579481
Using the mark strings to identify points in a TPointSeries works but I would like to make a small adjustment in their positions of the labels. The labels are a little too high - especially if I use a larger font. I would prefer the text to be centered vertically on each symbol.

Thanks,

Jim

Re: Adjust positions of marks in a TPointSeries?

Posted: Mon Jul 17, 2017 1:51 pm
by Christopher
Hello Jim,

If you have the Series Marks set to transparent, you could always use instead custom text drawing e.g.

Code: Select all

procedure TForm1.AfterDraw(Sender: TObject);
var t, w, h:Integer;
    str: String;
begin
   Chart1.Canvas.Font.Size:=12;

   for t := 0 to Series1.Count do
   begin
      str:=FloatToStr(Series1.YValues[t]);
      w:=Chart1.Canvas.TextWidth(str) div 2;
      h:=(Chart1.Canvas.TextHeight(str) div 2) - (Series1.Pointer.VertSize div 2);
      Chart1.Canvas.TextOut(Series1.CalcXPos(t) - w, Series1.CalcYPos(t) - h, str);
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D := False;


  Series1.FillSampleValues();
  {Series1.Marks.Visible:=true;
  Series1.Marks.Transparent:=true;
  Series1.Marks.Font.Size:=16;}

  Chart1.OnAfterDraw:=AfterDraw;
end;
which gives you this:
Project1_2017-07-17_15-51-31.png
Project1_2017-07-17_15-51-31.png (32.68 KiB) Viewed 8135 times

Re: Adjust positions of marks in a TPointSeries?

Posted: Mon Jul 17, 2017 4:47 pm
by 16579481
Thanks, it looks like that might work - although more complex than just a position option for point markers. I will try it.

Jim

Re: Adjust positions of marks in a TPointSeries?

Posted: Tue Jul 18, 2017 10:41 am
by yeray
Hello,

If it fits your needs, a simpler alternative could be to just set a negative ArrowLength. Ie:

Code: Select all

  Chart1.View3D:=False;
  Chart1.Legend.Visible:=False;

  Series1.FillSampleValues(10);

  Series1.Marks.Visible:=true;
  Series1.Marks.Font.Size:=16;
  Series1.Marks.Transparent:=True;
  Series1.Marks.ArrowLength:=-Series1.Marks.Font.Size;
  Series1.Marks.Arrow.Visible:=False;