CPlot:FindNearest CPlot:FindNearestY

CPlot:FindNearestX


The FindNearestX method returns the plot series index of the point with x coordinate nearest a target x value.

Syntax

nIndex, xPt = CPlot:FindNearestX( x )

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    xPt is the x coordinate of the nearest point.

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

Example

The following script finds the index of the point with x coordinate nearest 4.2 in series 1 of a CPlotView:

V = attachlist_plotview()

-- select the target plot window

if V == nil then Exit() 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

 

nTargX = 4.2

-- find the point nearest x=4.2

n, xPt = P:FindNearestX( nTargX )

-- get index n and value x

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

-- print the result

Related Topics

CPlotView class

CPlot class

FindNearest

FindNearestY

 


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