Adjust positions of marks in a TPointSeries?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Adjust positions of marks in a TPointSeries?

Post by JimR » Sat Jul 15, 2017 5:03 pm

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

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Adjust positions of marks in a TPointSeries?

Post by Christopher » Mon Jul 17, 2017 1:51 pm

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 7644 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

JimR
Newbie
Newbie
Posts: 46
Joined: Mon Oct 24, 2016 12:00 am

Re: Adjust positions of marks in a TPointSeries?

Post by JimR » Mon Jul 17, 2017 4:47 pm

Thanks, it looks like that might work - although more complex than just a position option for point markers. I will try it.

Jim

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Adjust positions of marks in a TPointSeries?

Post by Yeray » Tue Jul 18, 2017 10:41 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply