The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 GraphLayer array
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

flieger

1 Posts

Posted - 05/01/2015 :  07:00:02 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.1
Operating System: Win7
Hello,
in order to plot different columns with a simpler code, I'd like to use an array of GraphLayer as follows:

GraphLayer gl[5];

Unfortunately this does not work and I get an error after executing a file similar to the following one:

Worksheet wks;
wks.Create();
GraphPage gp[5];
for (int j=0; j<=4;j++){
 gp[j].Create();
}
GraphLayer gl[5];
DataRange dr[5];
for (int i=0; i<=4;i++){
 dr[i].Add(wks,0,"X");
 dr[i].Add(wks,i+1,"Y");
 gl[i]=gp[i].Layers(); <-error
 gl[i]=AddPlot(dr[i], IDM_PLOT_LINESYMB);
 gl[i].Rescale();

}

Does Origin support arrays of graph layers? Is the initialization correct?

jasonzhao

China
262 Posts

Posted - 05/04/2015 :  05:45:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello flieger,

Please refer to the code below, and check with the execute results.


void GraphLayer_AddPlot()
{
    Worksheet wks=Project.ActiveLayer();  // get the active worksheet
    
    for(int i=1;i<5;i++){
    DataRange dr;    
    dr.Add(wks, 0, "X");
    dr.Add(wks, i, "Y");  //plot the 1_ith columns as XY scatter
    GraphPage gp;
    gp.Create("origin");
    GraphLayer gl = gp.Layers();
    gl.AddPlot(dr, IDM_PLOT_SCATTER);
    gl.Rescale();
    gp.SetShow();
    }   
}




Best regards!
Jason
OriginLab Technical Service

Edited by - jasonzhao on 05/04/2015 05:47:30 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000