cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Jackie_
Level VI

Radio button on Graph builder to vary Variable Role("Y)

Hi,

 

I want to create a RB where you can change three variables Resistance, Currents, Voltage using Radio buttons. 

Here's what I have tried but something doesn't seem to be correct. Any advice?

Names Default To Here( 1 );

stk = Current Data Table();
col = stk << Get Column Names( "String" );

Resist = {};
curr = {};
Volt = {};
For( i = 1, i <= N Items( col ), i++,
	If(
		Contains( col[i], "Resistance" ), 
       Insert Into( Resist, col[i] ), 
  
  
		Contains( col[i], "Currents" ), 
		Insert Into( curr, col[i] ), 

		Contains( col[i], "Voltage" ), 
	
			Insert Into( Volt, col[i] ),

	)

);



New Window( "", 

	
	H List Box(

		
		V List Box(
	

			Radio Box(
				{"Resitance", "Currents", "Voltage"}, 

				<<SetFunction(
					Function( {neb}, 
						
						sel = neb << get selected;
						If(
							sel == "Resistance",
								For Each( {col, index}, Resit,
									obj << Remove Variables( N Items( obj << get variables() ), Role( "Y" ) );
									gb << add variables( col, Role( "Y" ), Position( index ) );
								), 
								 
							sel == "Currents",
								For Each( {col, index}, curr,
									obj << Remove Variables( N Items( obj << get variables() ) );
									gb << add variables( col, Role( "Y" ), Position( index ) );
								), 
								
							sel == "Voltage",
								For Each( {col, index}, Volt,
									obj << Remove Variables( N Items( obj << get variables() ) );
									gb << add variables( col, Role( "Y" ), Position( index ) );
								);
								
								
								
								 
							
							
							
						)
						
						
						
						;
					)
				)
			)
	
	
	
	
		), 

		V List Box(
			obj = stk << Graph Builder(
				Size( 518, 543 ),
				Show Control Panel( 0 ),
				Variables(
					X( :Resistance A5, Combine( "Parallel Merged" ) ),
					X( :Resistance A6, Position( 1 ), Combine( "Parallel Merged" ) ),
					X( :Resistance A7, Position( 1 ), Combine( "Parallel Merged" ) ),
					X( :Resistance A8, Position( 1 ), Combine( "Parallel Merged" ) ),
					X( :Resistance A9, Position( 1 ), Combine( "Parallel Merged" ) ),
					X( :Resistance A10, Position( 1 ), Combine( "Parallel Merged" ) ),
					X( :Resistance A11, Position( 1 ), Combine( "Parallel Merged" ) )
				),
				Elements(
					Box Plot( X( 1 ), X( 2 ), X( 3 ), X( 4 ), X( 5 ), Legend( 2 ) ),
					Histogram( X( 1 ), X( 2 ), X( 3 ), X( 4 ), X( 5 ), Legend( 3 ) )
				), 

			);
			gb = Report( obj )[Graph Builder Box( 1 )];
			obj << Parallel Axis Merging( "High Similarity" );

		)
	)
	
);

 Thanks,

Jackie

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Radio button on Graph builder to vary Variable Role("Y)

I made quite a lot of small changes, fixing typos and so on

Names Default To Here(1);

stk = Open("$DOWNLOADS/datatable.jmp");
col = stk << Get Column Names("String");

Resist = {};
curr = {};
Volt = {};
For(i = 1, i <= N Items(col), i++,
	If(
		Contains(col[i], "Resistance"), Insert Into(Resist, col[i]), 
		Contains(col[i], "Currents"), Insert Into(curr, col[i]), 
		Contains(col[i], "Voltage"), Insert Into(Volt, col[i]), 
		show("?");
	)
);


nw = New Window("", 
	H List Box(
		V List Box(
			Radio Box(
				{"Resitance", "Currents", "Voltage"}, 
				<<SetFunction(
					Function({neb},
						While(N Items(obj << get variables()),
							obj << Remove Variable(1)
						);
						sel = neb << get selected;
						If(sel == "Resitance",
							For Each({col, index}, Resist,
								Eval(EvalExpr(
									gb << add variable({Expr(Column(col)), Role("X"), Position(1), Combine("Parallel Merged")});
								));
							)
						, sel == "Currents",
							For Each({col, index}, curr,
								Eval(EvalExpr(
									gb << add variable({Expr(Column(col)), Role("X"), Position(1), Combine("Parallel Merged")});
								));
							)
						,sel == "Voltage",
							For Each({col, index}, Volt,
								Eval(EvalExpr(
									gb << add variable({Expr(Column(col)), Role("X"), Position(1), Combine("Parallel Merged")});
								));
							)
						);
					)
				)
			)
		), 
		V List Box(
			obj = stk << Graph Builder(
				Size(518, 543),
				Show Control Panel(0),
				Variables(
					X(:Resistance A5, Combine("Parallel Merged")),
					X(:Resistance A6, Position(1), Combine("Parallel Merged")),
					X(:Resistance A7, Position(1), Combine("Parallel Merged")),
					X(:Resistance A8, Position(1), Combine("Parallel Merged")),
					X(:Resistance A9, Position(1), Combine("Parallel Merged")),
					X(:Resistance A10, Position(1), Combine("Parallel Merged")),
					X(:Resistance A11, Position(1), Combine("Parallel Merged"))
				),
				Elements(
					Box Plot(X(1), X(2), X(3), X(4), X(5), Legend(2)),
					Histogram(X(1), X(2), X(3), X(4), X(5), Legend(3))
				), 

			);
			gb = Report(obj)[Graph Builder Box(1)];
			obj << Parallel Axis Merging("High Similarity");
		)
	)
);
-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Radio button on Graph builder to vary Variable Role("Y)

I made quite a lot of small changes, fixing typos and so on

Names Default To Here(1);

stk = Open("$DOWNLOADS/datatable.jmp");
col = stk << Get Column Names("String");

Resist = {};
curr = {};
Volt = {};
For(i = 1, i <= N Items(col), i++,
	If(
		Contains(col[i], "Resistance"), Insert Into(Resist, col[i]), 
		Contains(col[i], "Currents"), Insert Into(curr, col[i]), 
		Contains(col[i], "Voltage"), Insert Into(Volt, col[i]), 
		show("?");
	)
);


nw = New Window("", 
	H List Box(
		V List Box(
			Radio Box(
				{"Resitance", "Currents", "Voltage"}, 
				<<SetFunction(
					Function({neb},
						While(N Items(obj << get variables()),
							obj << Remove Variable(1)
						);
						sel = neb << get selected;
						If(sel == "Resitance",
							For Each({col, index}, Resist,
								Eval(EvalExpr(
									gb << add variable({Expr(Column(col)), Role("X"), Position(1), Combine("Parallel Merged")});
								));
							)
						, sel == "Currents",
							For Each({col, index}, curr,
								Eval(EvalExpr(
									gb << add variable({Expr(Column(col)), Role("X"), Position(1), Combine("Parallel Merged")});
								));
							)
						,sel == "Voltage",
							For Each({col, index}, Volt,
								Eval(EvalExpr(
									gb << add variable({Expr(Column(col)), Role("X"), Position(1), Combine("Parallel Merged")});
								));
							)
						);
					)
				)
			)
		), 
		V List Box(
			obj = stk << Graph Builder(
				Size(518, 543),
				Show Control Panel(0),
				Variables(
					X(:Resistance A5, Combine("Parallel Merged")),
					X(:Resistance A6, Position(1), Combine("Parallel Merged")),
					X(:Resistance A7, Position(1), Combine("Parallel Merged")),
					X(:Resistance A8, Position(1), Combine("Parallel Merged")),
					X(:Resistance A9, Position(1), Combine("Parallel Merged")),
					X(:Resistance A10, Position(1), Combine("Parallel Merged")),
					X(:Resistance A11, Position(1), Combine("Parallel Merged"))
				),
				Elements(
					Box Plot(X(1), X(2), X(3), X(4), X(5), Legend(2)),
					Histogram(X(1), X(2), X(3), X(4), X(5), Legend(3))
				), 

			);
			gb = Report(obj)[Graph Builder Box(1)];
			obj << Parallel Axis Merging("High Similarity");
		)
	)
);
-Jarmo
Jackie_
Level VI

Re: Radio button on Graph builder to vary Variable Role("Y)

Thanks @jthi. I noticed that the elements in the graph builder change after varying the RB. Is there a way I can retain the elements settings to box plot and histogram? 

Elements( Box Plot( X( 1 ), X( 2 ), X( 3 ), X( 4 ), Legend( 2 ) ), Histogram( X( 1 ), X( 2 ), X( 3 ), X( 4 ), Legend( 3 ) ) )

 

jthi
Super User

Re: Radio button on Graph builder to vary Variable Role("Y)

Depending on which options are changing easiest option might be to rebuild the Graph Builder when radio box option is changed. The format is fairly simple for this graph builder and creating expression/function for it isn't too bad ( Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute is most likely needed for it)

-Jarmo
Jackie_
Level VI

Re: Radio button on Graph builder to vary Variable Role("Y)

@jthi Thanks. I looked at the discussion but little confused. You mind sharing an example for reference?