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
 Title 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

meluks

4 Posts

Posted - 03/17/2011 :  1:03:46 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: OriginPro 8G SR1
Operating System: Win XP SP3

Hi all,

I try to add a title on top of my graph with OriginC. The title should be the Longname of the Workbook.
Maybe one of you knows how I could do this... Would be great!
Thanks a lot!
Melanie

Penn

China
644 Posts

Posted - 03/17/2011 :  11:04:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Melanie,

You can add a text graph object as title. Then set LongName of the workbook as text, and change position to the right place. Please refer to the following example.

void add_title()
{
    GraphLayer gl = Project.ActiveLayer();  // get the active graph layer
    if(!gl)
    	return;
    
	DataPlot dp = gl.DataPlots(0);  // get the first dataplot in the layer
	if(!dp)
		return;
	
	string strDatasetName = dp.GetDatasetName();  // get data range of the plot
	string strBookShortName = strDatasetName.GetToken(0, '_');  // get short name of the workbook
	WorksheetPage wp(strBookShortName);
	if(!wp)
		return;
	
	string strBookLongName = wp.GetLongName();  // get long name of the workbook
	
    GraphObject go = gl.CreateGraphObject(GROT_TEXT, "MyTitle");  // create a text object
    if( go )
    {
    	go.Text = strBookLongName;  // set long name to the text object
    	go.Attach = 2; // attach text object to layer, 0 to Layer; 1 to Page; 2 to Axes
    	go.X = gl.X.From+(gl.X.To-gl.X.From)/2.0;  // middle of the X axis;
    	go.Y = gl.Y.To+go.DY;  // top of the layer
    }        
    gl.GetPage().Refresh();  // refresh the graph
}


Penn
Go to Top of Page

meluks

4 Posts

Posted - 03/18/2011 :  04:52:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Penn,

your example works great! Thanks a lot!

Melanie
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