【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.1.7.5 find_nearest_xy_at_x
Contents
Description
For the given data range which is constructed from a graph layer, find the data plot xy values according to the given x
Syntax
bool find_nearest_xy_at_x( double x, const DataRange & dr, vector<string> & vsNames, vector<int> & vnIndices, vector & vx, vector & vy )
Parameters
- x
- [input] given x value
- dr
- [input] data range of data plots
- vsNames
- [output] data plots' name
- vnIndices
- [output] data plots' indices
- vx
- [output] data plots' x value
- vy
- [output] data plots' y value
Return
True for success, otherwise return false
Examples
EX1
void find_nearest_xy_at_x_ex1() { Worksheet wks; wks.Create("origin"); Dataset ds1(wks,0); Dataset ds2(wks,1); ds1.Data(1,20,1); ds2.Data(20,1,-1); GraphPage gp; gp.Create("origin"); GraphLayer gl(gp.GetName(), 0); gl.AddPlot(wks); Tree tr; if(gl) { construct_data_range_all_plots(tr, gl); out_tree(tr); DataRange dr; dr.Create(tr, false); vector<string> vsNames; vector<int> vnIndices; vector vx, vy; double x = 3;//change the input x to other values to see different results if(find_nearest_xy_at_x(x, dr, vsNames, vnIndices, vx, vy)) { for(int ii = 0; ii < vsNames.GetSize(); ii++) { //when input x is 3,the corresponding value in dataplot are :index = 2, x = 3, y = 18 printf("\n%s: index = %d, x = %g, y = %g\n", vsNames[ii], vnIndices[ii], vx[ii], vy[ii]); } } } }
Remark
See Also
Header to Include
origin.h