cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
ARETI052
Level III

For Loops and Column Lists

Hi, 

I am intending to build a Graph Builder for visualizing different columns of data each time. The Graph Builder should be able to take whatever many inputs columns (as long as it's less than 8). I built an input GUI but I dont think the y-values are recorded. How can I correctly pass the selected Y column data to the graph builder? Thanks!

ARETI052_0-1719509829133.pngARETI052_1-1719509852246.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
hogi
Level XII

Re: For Loops and Column Lists

You could prepare your Variables first and then use insert into to put them into Graph builder.

 

MyGraph = Function ({yCol,xCol},{default local},

vars= 	Eval Expr(Variables(
		X( Expr(xCol) ),
		Group X( :Temperature )
	));
	
	pts= Expr(Points( X));

	For(j = 1, j <= Min(8, N Items(yCol)), j++,
               Insert Into(vars, Eval Expr(Y( Expr(yCol[j]))));
            );
	
	gb = Expr(
		Graph Builder(
		));
	Insert Into(gb, Name Expr(vars));	
	VListBox(gb)
);

View solution in original post

7 REPLIES 7
txnelson
Super User

Re: For Loops and Column Lists

Please use the txnelson_0-1719510632610.png icon to display your JSL.  It allows for the reader to test your code and provide responses.  Pasting in images of your code will not allow this, and therefore many possible responders will opt not to respond because of the time it would take to retype in your JSL

 

Jim
ARETI052
Level III

Re: For Loops and Column Lists

names Default To Here(1);

MyGraph = Function ({yCol,xCol},{default local},
	
	vlb = VListBox(
		Graph Builder(
	Size( 1255, 981 ),
	Show Control Panel( 0 ),
	Variables(
		X( Eval(xCol) ),
		For(j = 1, j <= Min(8, N Items(yCol)), j++,
                Y( Eval(yCol[j]))  // Evaluate each yVar
            ),
		Group X( :Temperature )
	),
	Elements( Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Y( 5 ), Y( 6 ), Y( 7 ), Y( 8 ), Legend( 11 ) ) ),
	Local Data Filter(
		Add Filter(
			columns( :Test Stage, :Sublot, :Temperature, :Soft Bin ),
			Display( :Test Stage, N Items( 4 ) ),
			Display( :Soft Bin, N Items( 15 ) )
		)
	)
)
		);
	
	
	return(vlb);
);




dt = CurrentDatatable();
nw = NewWindow("Column Selection", <<modal,
	<<onClose(
		lstX = clbX << getItems;
		lstY = clbY << getItems;
	),
	BorderBox(top(10),bottom(10),left(10),right(10),
		VListBox(
			TextBox("Select X and Y variables"),
			HListBox(
				PanelBox("Select Columns",
					fcs = FilterColSelector()
				),
				SpacerBox(size(10,0)),
				PanelBox("Cast Selected Columns into Roles",
					HListBox(
						ButtonBox("Y,Response",
							sel = fcs << getSelected; 
							clbY << append(sel);
						),
						SpacerBox(size(6,0)),
						clbY = CollistBox(numeric,maxitems(8),minitems(1),nlines(8))
					
					),
					HListBox(
						ButtonBox("X,Variable",
							sel = fcs << getSelected; 
							clbX << append(sel);
							
						),
						SpacerBox(size(6,0)),
						clbX = CollistBox(maxitems(2),minitems(1),nlines(2))	
				
					)
				)	
			)
		) 	
	)
);
if (nw["Button"]==-1,throw());
if (Nitems(lstX)==0,throw());
if (Nitems(lstY)==0,throw());

yColName = lstY; 
xColName = lstX;
show(lstY,lstX);
NewWindow("My report",
	VListBox(
		MyGraph(yColName,xColName),
		HCenterBox(
		btn = ButtonBox("show distribution")
		)
	)
);

btn << setScript(
MyHistograms()
);
ARETI052
Level III

Re: For Loops and Column Lists

Thanks for the advice, here is my full script.

ARETI052
Level III

Re: For Loops and Column Lists

The embedded log is showing "Specified Column not found in data table. in access or evaluation of 'For' , For/*###*/(j = 1, j <= Min( 8, N Items( yCol ) ), j++, Y( Eval( yCol[j] ) ))"

But I used the column is clearly in my data table.

hogi
Level XII

Re: For Loops and Column Lists

You could prepare your Variables first and then use insert into to put them into Graph builder.

 

MyGraph = Function ({yCol,xCol},{default local},

vars= 	Eval Expr(Variables(
		X( Expr(xCol) ),
		Group X( :Temperature )
	));
	
	pts= Expr(Points( X));

	For(j = 1, j <= Min(8, N Items(yCol)), j++,
               Insert Into(vars, Eval Expr(Y( Expr(yCol[j]))));
            );
	
	gb = Expr(
		Graph Builder(
		));
	Insert Into(gb, Name Expr(vars));	
	VListBox(gb)
);
hogi
Level XII

Re: For Loops and Column Lists

Things like this will get easier once 🙏 Expression Indexing: read and write access will be available in future version of JMP ...
Then you don't have to prepare the different parts and then construct your final expression, you can directly create a draft of the final expression and then manipulate it on any level you want.

e.g. add Y column to an existing Graph builder Expression via :

gbExpression= Expr(Graph Builder(Variables(X(:height))));
Insert Into ( gbExpression["Variables"], Expr(Y(:age)))

 

ARETI052
Level III

Re: For Loops and Column Lists

It worked! Thank you so much!