TAChart: Add TDataPointTool.TPointRef.AxisPos function

git-svn-id: trunk@38330 -
This commit is contained in:
ask 2012-08-22 10:51:36 +00:00
parent aa894b143a
commit f5b873aa42

View File

@ -349,6 +349,7 @@ type
procedure SetGraphPos(const ANewPos: TDoublePoint); procedure SetGraphPos(const ANewPos: TDoublePoint);
public public
procedure Assign(ASource: TPointRef); procedure Assign(ASource: TPointRef);
function AxisPos: TDoublePoint;
property GraphPos: TDoublePoint read FGraphPos; property GraphPos: TDoublePoint read FGraphPos;
property Index: Integer read FIndex; property Index: Integer read FIndex;
property Series: TBasicChartSeries read FSeries; property Series: TBasicChartSeries read FSeries;
@ -618,6 +619,15 @@ begin
end; end;
end; end;
function TDataPointTool.TPointRef.AxisPos: TDoublePoint;
begin
if Series = nil then
Result := GraphPos
else
with Series do
Result := DoublePoint(GraphToAxisX(GraphPos.X), GraphToAxisY(GraphPos.Y));
end;
procedure TDataPointTool.TPointRef.SetGraphPos(const ANewPos: TDoublePoint); procedure TDataPointTool.TPointRef.SetGraphPos(const ANewPos: TDoublePoint);
begin begin
FGraphPos := ANewPos; FGraphPos := ANewPos;
@ -1767,23 +1777,20 @@ function TDataPointDistanceTool.Distance(AUnits: TChartUnits): Double;
var var
p1, p2: TDoublePoint; p1, p2: TDoublePoint;
begin begin
p1 := PointStart.GraphPos;
p2 := PointEnd.GraphPos;
case AUnits of case AUnits of
cuPercent: exit(0); // Not implemented. cuPercent: exit(0); // Not implemented.
cuAxis: begin cuAxis: begin
if PointStart.Series <> nil then p1 := PointStart.AxisPos;
with PointStart.Series do p2 := PointEnd.AxisPos;
p1 := DoublePoint(GraphToAxisX(p1.X), GraphToAxisY(p1.Y)); end;
if PointEnd.Series <> nil then cuGraph: begin
with PointEnd.Series do p1 := PointStart.GraphPos;
p2 := DoublePoint(GraphToAxisX(p2.X), GraphToAxisY(p2.Y)); p2 := PointEnd.GraphPos;
end; end;
cuGraph: ;
cuPixel: begin cuPixel: begin
with FChart.GraphToImage(p1) do with FChart.GraphToImage(PointStart.GraphPos) do
p1 := DoublePoint(X, Y); p1 := DoublePoint(X, Y);
with FChart.GraphToImage(p2) do with FChart.GraphToImage(PointEnd.GraphPos) do
p2 := DoublePoint(X, Y); p2 := DoublePoint(X, Y);
end; end;
end; end;