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
 set axis tick labels from dataset programmatically
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

adickson

2 Posts

Posted - 08/30/2011 :  4:36:57 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 8.5.1 SR2
Mac OSX 10.6.8

I would like to be able to programmatically use a dataset for my axis tick labels.

It looks like I should be able to use this to select the "text from dataset" option for the x axis:
tr.Root.Labels.BottomLabels.Type.nVal = 1;

but where/how do I specify the actual dataset to use?

thanks,
andrea

Penn

China
644 Posts

Posted - 08/30/2011 :  11:35:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi andrea,

It seems that such option for Origin C is not exposed yet. For now, you can use the LT_execute to call some LabTalk to do that. For example:

void testTicks() {
	GraphLayer gl = Project.ActiveLayer();  // the active graph layer
	string strLTCmd;
	strLTCmd = "layer.x.label.Type = 2;";  // set tick labels from dataset
	strLTCmd += "layer.x.label.dataset$ = Book1_C;";  // set column C in Book1 as tick labels
	gl.LT_execute(strLTCmd);  // execute LabTalk script
}

You can get more information here about layer.axis.label object.

Penn
Go to Top of Page

adickson

2 Posts

Posted - 09/06/2011 :  10:29:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
that worked great! thanks.

for others that are trying this - i couldn't find much documentation on the "internal name" that you need to use when specifying the dataset (especially if you have multiple sheets in the book). i was able to access it using a labtalk script:
range rr = "[Book2]risetime!C";
nameof(rr)$=

Book2_C@12

and the format it uses is: bookname_colname@sheetnum
in originc you can get the sheet number to use by calling
wks.GetIndex() + 1

if someone knows of a link with more info about internal names, can you please post it?

thanks!
andrea
Go to Top of Page

Penn

China
644 Posts

Posted - 09/06/2011 :  10:27:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi andrea,

Yes, you can use the format bookname_colname@sheetnum. There is no detail document on this because this usage is old, and you can refer to this example. I am very sorry showing you this. Actually, you can use the range directly. For example:

range rr = [Book2]risetime!C;
layer.x.label.dataset$ = rr;


Penn
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