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
 Extracting both x and y data from GetN 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
michaelbraun Posted - 07/10/2015 : 5:20:25 PM
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015 sr2
Operating System: Windows

Hi, I am attempting to select a certain data range on a plot using GetN. I get the dialog to come up and successfully select the correct data. However, I can only get the y data points to export? I think I am missing a dr.Add command, but I don't know what to reference to get the x points corresponding to each y point?

My header and relevant code, the last 2 lines add the grabbed y data points to the appropriate column in my worksheet:

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>

                        GETN_TREE(gettr)	
			GETN_INTERACTIVE(Range1, "Select Range", "Graph")
			vector yData, xData;
			if( GetNBox(gettr) ) // returns true if click OK button
			{
				DataRange dr;
				dr.Add("Range1", gettr.Range1.strVal);
				dr.GetData(&yData, 0); //0 is the index location of data
				dr.GetData(&xData, 1); //This doesn't do anything right now, but I would like it to.
			}
		
		
		//write selected data to original worksheet
				vectorbase& vy = wks.Columns(4).GetDataObject();
				vy = yData;


2   L A T E S T    R E P L I E S    (Newest First)
michaelbraun Posted - 07/10/2015 : 9:54:55 PM
Worked great, thank you! Just a note for anyone else coming across this, if you want to use the selected data placed into the xData and yData vectors, they need to be initialized outside the if statement. My section of working code is:

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>
                //Select data from graph
                        GETN_TREE(gettr)	
			GETN_XYRANGE(Range1, "Select Range", 1, "")
			vector yData, xData;
			if( GetNBox(gettr) ) // returns true if click OK button
			{
				XYRange dr;
				xy_range_from_GetN_data_node(gettr.Range1.Range1, dr);
				dr.GetData(yData, xData);
			}
			
		//write selected data to original worksheet
				vectorbase& vy = wks.Columns(4).GetDataObject();
				vy = yData;
				vectorbase& vx = wks.Columns(3).GetDataObject();
				vx = xData;





Castiel Posted - 07/10/2015 : 9:03:10 PM
quote:
Originally posted by michaelbraun

Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015 sr2
Operating System: Windows

Hi, I am attempting to select a certain data range on a plot using GetN. I get the dialog to come up and successfully select the correct data. However, I can only get the y data points to export? I think I am missing a dr.Add command, but I don't know what to reference to get the x points corresponding to each y point?

My header and relevant code, the last 2 lines add the grabbed y data points to the appropriate column in my worksheet:

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>

                        GETN_TREE(gettr)	
			GETN_INTERACTIVE(Range1, "Select Range", "Graph")
			vector yData, xData;
			if( GetNBox(gettr) ) // returns true if click OK button
			{
				DataRange dr;
				dr.Add("Range1", gettr.Range1.strVal);
				dr.GetData(&yData, 0); //0 is the index location of data
				dr.GetData(&xData, 1); //This doesn't do anything right now, but I would like it to.
			}
		
		
		//write selected data to original worksheet
				vectorbase& vy = wks.Columns(4).GetDataObject();
				vy = yData;





Should have been GETN_XYRANGE.

GETN_TREE(gettr)	
//GETN_INTERACTIVE(Range1, "Select Range", "Graph")
GETN_XYRANGE(Range1, "Select Range", 1, "")
if( GetNBox(gettr) ) // returns true if click OK button
{
    XYRange dr;
    xy_range_from_GetN_data_node(gettr.Range1.Range1, dr);
			 
    vector xData, yData;
    dr.GetData(yData, xData);
}


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦

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