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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Title of a graph

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
meluks Posted - 03/17/2011 : 1:03:46 PM
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
2   L A T E S T    R E P L I E S    (Newest First)
meluks Posted - 03/18/2011 : 04:52:35 AM
Hi Penn,

your example works great! Thanks a lot!

Melanie
Penn Posted - 03/17/2011 : 11:04:21 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000