For x value, find the nearest point from a data plot and returns the index of this point.
int get_dataplot_index( DataPlot & dp, double x, DWORD dwCntrl = XIC_NEAREST_ANY )
-1 if no point found, else returns the index of the point.
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); }
origin.h