DataPlot::XIndex

Description

Given X value get the index of point in DataPlot.

Syntax

int XIndex( double dX, int & nIndex, DWORD dwCntrl = XIC_NEAREST_ANY )

Parameters

dX
[input]X value.
nIndex
[output] reference to point index.
dwCntrl
[input] additional control, Can be
XIC_NEAREST_LEFT
XIC_NEAREST_RIGHT
XIC_NEAREST_ANY
XIC_EXACT_OR_NEAREST_LEFT
XIC_EXACT_OR_NEAREST_RIGHT

Return

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

Examples

void DataPlot_XIndex_Ex1()
{
        //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 )
                {
                        int nIndex;
                        double xValue = 6.6;
                        if ( XIR_ERROR != dp.XIndex(xValue, nIndex) )
                        {
                                printf("Nearest point's index is %d", nIndex);
                        }
                        else
                                printf("No nearest point found!");
                }
        }
        return;
}

Remark

See Also

Header to Include

origin.h