Dear specialists
I try to develop a standard procedure for a helping tool in a chart.
The basis is “ chpointsbasicmaster” : a chart which provides the available data ( in my test case 60 points).
Then i have standard chpointsLinserie1: achart with evenly distributed zigzag line (20 points here)
The idea is to use to the points of the zigzag line and then drag them to one of the points of the “ chpointsbasicmaster”-line. This dragging should take place in such a way that we keep the sorted character of the zigzag points.
Once we have dragged close to the “chpointsbasicmaster” the nearest point of the “chpointsbasicmaster” should be grabbed and its xy values should become the new values of the zigzag point of the chpointsLinserie1.
for the dragging and snapping i try to use following code:
procedure TForm1.ctPointsDataPointDragTool1Drag(ASender: TDataPointDragTool;
var AGraphPoint: TDoublePoint);
var thspoint:integer;
anx,any:double;
AmasterGraphPoint : TDoublePoint;
p: TNearestPointParams;
r: TNearestPointResults;
begin
draggedpoint:= ctPointsDataPointDragTool1.PointIndex ; // affected series = chpointsLinserie1
if ((AGraphPoint.x >= minimumX)and(AGraphPoint.x <= maximumX)) then
begin
RposX[draggedpoint]:=AGraphPoint.x; //during dragging
RposY[draggedpoint]:= AGraphPoint.y;//during dragging
memo1.Lines.add(' draggedpoint= '+inttostr( draggedpoint)+' Rx= '+floattostr(RposX[draggedpoint])+' Ry= '+floattostr(RposY[draggedpoint]));
end;
// p.FDistFunc := @PointDistX; // got error when using this
p.FOptimizeX := true;
p.FPoint := chPoints.GraphToImage(aGraphPoint);
p.FRadius := 15;
if chpointsbasicmaster.GetNearestPoint(p, r) then
begin
AmasterGraphPoint := chpointsbasicmaster.AxisToGraph(r.FValue);
RposX[draggedpoint]:=AmasterGraphPoint.x; // a detected nearest point
RposY[draggedpoint]:= AmasterGraphPoint.y;
AGraphPoint:=AmasterGraphPoint ; //overriding
anx:=AGraphPoint.x;
any:= AGraphPoint.y;
memo1.lines.add(' nearest point x='+floattostr(anx)+' any='+floattostr(any));
end else memo1.Lines.add( 'not working') ;
end;
it compiles oke , but "if chpointsbasicmaster.GetNearestPoint(p, r) then" is not getting true
// p.FDistFunc := @PointDistX;results in an error
i suspect the "@"which is not recognised in my case ,i do not know what to do with it
i would appriciate some suggestions how to solve this