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;
Thanks,
Mark