Set the subrange at the given index.
BOOL SetRange( int nIndex, Datasheet & ds, int nR1, int nC1, int nR2, int nC2, LPCSTR lpcszName = NULL )
Returns TRUE on successful exit and FALSE on failure.
EX1
// Draw two dataplots using the data in the worksheet as XYY. void DataRange_SetRange_Ex1(int nXCol = 0, int nYCol = 1, int nPlots = 1) { //Create a worksheet with three columns and fill with data. Worksheet wks; wks.Create("Origin"); if( !wks ) return; while(wks.Columns(0)) wks.DeleteCol(0); int nColIndex =0; for(int n=0; n< nPlots +2; n++) nColIndex = wks.AddCol(); for(int i=0;i<nPlots+2;i++) { for (int j=0;j<10;j++) { double rr=rnd(); wks.SetCell(j,i,rr*100); } } //Create a datarange with two subranges X and Y. DataRange dr; dr.Add(wks, nXCol, "A"); dr.Add(wks, nYCol, "B"); dr.SetRange(0, wks, 0, nXCol, -1, nXCol, "X"); // Rename range to X for plotting dr.SetRange(1, wks, 0, nYCol, -1, nYCol, "Y"); // Rename range to Y for plotting GraphPage gp; gp.Create("Origin", CREATE_HIDDEN); if( gp ) { GraphLayer gl = gp.Layers(); if( gl ) { int nPlotIndex, iColor; iColor = 0; // Index in Origin color list 0=Black, 1=Red, etc. DataPlot dp; for(int ii = 0; ii < nPlots+1; ii++) { dr.SetRange(1, wks, 0, nYCol + ii, -1, nYCol + ii, NULL); // Change Y range but do not rename nPlotIndex = gl.AddPlot(dr, IDM_PLOT_SCATTER); dp = gl.DataPlots(nPlotIndex); if( dp ) dp.SetColor(iColor++, TRUE ); // Set color of current DataPlot } gl.Rescale(); gp.SetShow(); } } }
Set the subrange at the given index. The subrange at the given index must exist.
DataRange::Add, DataRange::AddInput
origin.h