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
 How to change the name of a graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

yulisunflower

USA
Posts

Posted - 10/28/2009 :  4:23:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 7.5 sr6
Operating System:Windows Vista
I wrote a small program to plot the fitting results of my data, I would like to name each graph by the column name of the data plotted instead of Graph1, Graph2 and so on. Any idea how to do that? My code is like this:

void AutoPlot(int ncol)
{
Worksheet wksData; // Declare Worksheet (Layer) object
Column col; // Declare Column object

int iColNum;
string strColName;

wksData = Project.ActiveLayer();// get the active layer, which is the fitted worksheet

for (iColNum=1;iColNum<=ncol;iColNum++)
{
// *** Use Worksheet class Columns collection to get second column and check column name ***
//col = wksData.Columns(iColNum); // Get second column in worksheet (0 based index)
//strColName = col.GetName(); // Get column name to check (just for fun)

//creat a graph
GraphPage grphData;
bool bRetG = grphData.Create("PCH2"); // use the "PCH2" template for graph

// Point to active layer in current graph page
GraphLayer grphLayer = grphData.Layers();

// Declare a curve object using x,y columns of worksheet
Curve crvData(wksData, 0, iColNum);
Curve crvFit(wksData,0,iColNum+ncol*2);

// Plot data curve to active layer
int nPlot = grphLayer.AddPlot(crvData, IDM_PLOT_LINESYMB);
int mplot = grphLayer.AddPlot(crvFit, IDM_PLOT_SCATTER);
grphLayer.Rescale();


}
}

Thanks a lot

Yu

Iris_Bai

China
Posts

Posted - 10/28/2009 :  9:36:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can use PageBase::Rename(LPCSTR lpcszNewName, BOOL bAskIfAlreadyUsed = FALSE). For example,

grphData.Rename(strColName);


Iris
Go to Top of Page

yulisunflower

USA
Posts

Posted - 10/29/2009 :  3:51:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That works! Thanks you very much.

Yu
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