Hi,
Please refer to the following example:
1. New a worksheet with three columns, filling with row number
2. Select the three columns to make two scatter plots, one in black and the other in red
//--> the red plot is on top
3. open layer content dialog to upgroup the two plots
4. run function test_changeplotorder() //--> the black plot should be on top
void test_changeplotorder()
{
GraphLayer glActive = Project.ActiveLayer();
if(!glActive)
return;
DataPlot dp2 = glActive.DataPlots(1);
if(!dp2)
return;
string strDPName = "DataPlot";
Tree trContents;
glActive.GetLayerContents( trContents, GETLC_DATAPLOTS );
TreeNode trContentsClone = trContents.Clone();
TreeNode trLayer = trContentsClone.FirstNode;
foreach(TreeNode trN in trLayer.Children)
{
if( trN.tagName.Find(strDPName) == 0 )
{
trN.Remove();
}
}
int nPlot = 0;
for(TreeNode trDataPlot = trContents.FirstNode.LastNode; trDataPlot.IsValid(); trDataPlot = trDataPlot.PrevNode)
{
if( trDataPlot.tagName.Find(strDPName) != 0 )
continue;
string strName = strDPName + (string)(++nPlot);
TreeNode trNew = trLayer.AddNode(strName);
trNew.Replace(trDataPlot, true, true, false);
trNew.DataID = nPlot;
}
DWORD dwAddPlotsCtrl = ADDPLOTSFROMTREE_EDIT|ADDPLOTSFROMTREE_IMPLICIT_STYLEHOLDERS;
int nNewPlotNum = glActive.AddPlots( trContentsClone.FirstNode, dwAddPlotsCtrl );
}
Best Regard,
Jessie
Originlab Corp.