Relative placement of marks

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Softdrill
Newbie
Newbie
Posts: 1
Joined: Fri Dec 28, 2012 12:00 am

Relative placement of marks

Post by Softdrill » Sat Jan 05, 2013 7:49 pm

Hi,

I have a chart with several Lines series. For each point on the series I wish to display a Mark, at a position relative (in pixels) to the point. After reading some suggestions on this forum, I have come to the following code which I place in the OnAfterDraw event.

Code: Select all

procedure TdlgSD_WellPlot.OnAfterDraw(Sender: TObject);
var
  APosition: TSeriesMarkPosition;
  ii, jj: Integer;
begin
  inherited;
  APosition := TSeriesMarkPosition.Create;
  try
    for ii := 0 to (Sender as TChart).SeriesList.Count - 1 do
    begin
      for jj := 0 to (Sender as TChart).Series[ii].ValuesList.Count - 1 do
      begin
        APosition.Custom := true;
        APosition.LeftTop.x := (Sender as TChart).Series[ii].CalcXPos(jj);
        APosition.LeftTop.y := (Sender as TChart).Series[ii].CalcYPos(jj);
        (Sender as TChart).Series[ii].Marks.Positions[jj] := APosition;
      end;
    end;
  finally
    APosition.Free;
  end;
end;
Using this code, the Marks do appear but remain "static" when panning or zooming the chart (i.e. don't move with the line series). Any suggestions to what I am doing wrong?

Thanks,
Mark

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

Re: Relative placement of marks

Post by Yeray » Mon Jan 07, 2013 9:25 am

Hi Mark,

I see in the second "for" you are looping from 0 to the Series ValuesList.Count-1. Note this ValuesList contains the array of ValueLists: XValues, YValues. So ValuesList.Count = 2. Try changing the second "for" for this:

Code: Select all

for jj := 0 to (Sender as TChart).Series[ii].Count - 1 do
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