Given X value get the index of point in DataPlot.
int XIndex( double dX, int & nIndex, DWORD dwCntrl = XIC_NEAREST_ANY )
XIR_ERROR if no nearest point is found corresponding to dwCntrl
XIR_WITHIN_RANGE if dX is within range of DataPlot
XIR_LEFT_OF_RANGE if dX is lower than lowest X value in DataPlot and dwCntrl is not equal to XIC_NEAREST_LEFT
XIR_RIGHT_OF_RANGE if dX is higher than highest X value in DataPlot and dwCntrl is not equal to XIC_NEAREST_RIGHT
//make sure there exists a graph with dataplots on it before running this code.
GraphLayer gl = Project.ActiveLayer();
if ( gl )
DataPlot dp = gl.DataPlots(0); //get the first dataplot on graphlayer
if ( dp )
double xValue = 6.6;
if ( XIR_ERROR != dp.XIndex(xValue, nIndex) )
printf("Nearest point's index is %d", nIndex);
printf("No nearest point found!");