get_dataplot_index
Description
For x value, find the nearest point from a data plot and returns the index of this point.
Syntax
int get_dataplot_index( DataPlot & dp, double x, DWORD dwCntrl = XIC_NEAREST_ANY )
Parameters
- dp
- [input] data plot object
- x
- [input] give x value to find point
- dwCntrl
- [input] control of the way to decide how to find the nearest point, default is XIC_NEAREST_ANY
Return
-1 if no point found, else returns the index of the point.
Examples
EX1
void get_dataplot_index_ex1()
{
WorksheetPage wksPage;
wksPage.Create("Origin");
Worksheet wks = wksPage.Layers();
Dataset dsA(wks, 0);
Dataset dsB(wks, 1);
dsA.Data(1, 10, 1);
dsB.Data(1, 10, 1);
GraphPage gp;
gp.Create();
GraphLayer gl = Project.ActiveLayer();
gl.AddPlot(wks);
DataPlot dp = gl.DataPlots();
int index = -1;
double x = 5.3;
DWORD dwCntrl = XIC_NEAREST_ANY;
index = get_dataplot_index(dp, x, dwCntrl); // index is 4, find the nearest one
printf("X is %f and dwCntrl is %d, the index of data point will be %d\n", x, dwCntrl, index);
dwCntrl = XIC_NEAREST_RIGHT;
index = get_dataplot_index(dp, x, dwCntrl); // index is 5, find the right one
printf("X is %f and dwCntrl is %d, the index of data point will be %d\n", x, dwCntrl, index);
}
Remark
See Also
header to Include
origin.h
Reference
|