The Origin Forum
File Exchange
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
 how to move legend

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

Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List

* Forum Code is ON
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
Eagleba91 Posted - 07/16/2012 : 2:21:03 PM
Does anyone know how to go above moving the legend? It is slightly covering the top of my y-axis on the right side with plenty of room to move it up a little. I have looked for hours both in the user's guide book and online to no avail.
3   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 07/18/2012 : 10:09:03 PM

I guess your graph contains more than one layer and the legend is not in the active layer when the error happens (I can reproduce it in such situation). You mentioned that it worked if you clicked on the legend, actually, this behavior had activated the layer with the legend. You can add the condition as following to test whether the object is valid.

    out_str("found no object.");

So, please first make sure the legend is in the graph layer gl in your code.

Eagleba91 Posted - 07/18/2012 : 09:39:48 AM
I have what I believe is the proper code to adjust the position of my legend. For some reason, it only works if I click on the legend to make it the active object though. If I take this code and put it at the end some code to generate a plot it gives me a command error saying, "Origin C Function Runtime Error, Calling members of unattached wrapper class."

// function for moving legend
GraphLayer gl = Project.ActiveLayer();
GraphObject go = gl.GraphObjects("Legend");

Tree tr;
tr.Root.Dimension.Left.dVal = gl.X.To - 23; //To=right, From=left
tr.Root.Dimension.Top.dVal = gl.Y.To+23; //to=top, from = bottom

if( 0 == go.UpdateThemeIDs(tr.Root))
{bool bRet = go.ApplyFormat(tr,true,true);
Penn Posted - 07/16/2012 : 10:56:32 PM

Actually, legend is a GraphObject, with the default name of "Legend". You can check the name by right-clicking on the legend, and then select Programming Control from the context menu. Then you will see the object name in the dialog. So, to change the legend position, you can refer to the example of modifying graph object position. For more details, please refer to here.


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