CPlot:Count CPlot:FindNearestX

CPlot:FindNearest


The FindNearest method returns the plot series index of the point nearest the target coordinates (x,y).

Syntax

nIndex, xPt, yPt = CPlot:FindNearest( x, y )

bullet.gif    nIndex is the index of the nearest point, from 1 to CPlot:Count.

bullet.gif    x is the x coordinate of the target point.

bullet.gif    y is the y coordinate of the target point.

bullet.gif    xPt is the x coordinate of the nearest point.

bullet.gif    yPt is the y coordinate of the nearest point.

bullet.gif    On failure, 0,0,0 is returned.

Example

The following script finds the index of the point nearest coordinates (4.2,-17.1) in series 1 of a CPlotView:

V = attachlist_plotview()

-- select the target plot window

if V == nil then Exit("Bad plot") end

-- if not successful, exit the script

P = V:GetPlot(1)

-- get a CPlot object for series 1

if P == nil then Exit("Bad series") end

 

n, xPt, yPt = P:FindNearest( 4.2, -17.1 )

-- get index n and coordinates

Printf("Nearest: Pt[%d]=(%lg,%lg)\n", n, xPt, yPt)

-- print the result

Related Topics

CPlotView class

CPlot class

FindNearestX

FindNearestY


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.