cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
mystylelife19
Level III

How to use Set Function {self}

Hi,

I explore all the question and answer inside this community and still not getting my answer to use this script. Can you help me, please?

 

I have data table with all the parameter (column) and data (row). My question is how to use Radio Box with the set function {self} to display all the data that i chosen one parameter on Radio Box to see at Bivariate (Fit Y by X).

 

I don't want to click OK to see the output on Bivariate, just click parameter on radio box.

 

I attach with example data table below,

Here my full script but still my radio box won't function using set function {self}

//Get the current data Table
Names Default To Here( 1 );
dt = Current Data Table();

// Get the all column names from the data table
columnNames = dt << Get Column Names("String");

cl = New Window("Column Selection", <<Modal,
		  Panel Box("Make a selection",
			  allcolumn = RadioBox(columnNames, 
			    <<Set Function(
			    Function({self},
						match(self << Get Selected,
							allcolumn, columnNames << Set //i don't know on how to set funtion {self} to all parameter
						)
					)
				)
			)	
		)
	); 

// If cancel or X was clicked, stop the script
If( cl == {Button( -1 )}, Stop() );	

Bivariate(
	Y( :Y ),
	X( :X ),
	By( :WAFER_ID, :SITE_NO ) );
	SendToReport(
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{Row Legend(
				allcolumn, //this one is referring to the radio box parameter for what i choosing
				Color( 1 ),
				Color Theme( "Spectral"(1) ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
			)}
		)
	);
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How to use Set Function {self}

dt = Open( "$sample_data/big class.jmp" );

columnNames = dt << Get Column Names( "String" );

cl = New Window( "Column Selection",
//	<<modal, // optional, probably not what you want
	H List Box(
		Panel Box( "Make a selection",
			allcolumn = Radio Box(
				columnNames,
				<<Set Function(
					Function( {self},
						col = self << get selected;
						Try( (reportHolder << child) << delete ); // remove old content
						reportholder << append( dt << Distribution( Nominal Distribution( Column( Eval( col ) ) ) ) );
					)
				)
			)
		),
		reportHolder = Border Box()
	)
);
Craige

View solution in original post

5 REPLIES 5
Craige_Hales
Super User

Re: How to use Set Function {self}

GUI design rules don't usually run code when a radio button is picked. You can break the rule, but users may not like it. This example will let you choose either path

dt = Open( "$sample_data/big class.jmp" );

// Get the all column names from the data table
columnNames = dt << Get Column Names( "String" );

cl = New Window( "Column Selection",
	<<Modal,
	<<Return Result, // this is the magic part you are missing
	Panel Box( "Make a selection",
		allcolumn = Radio Box(
			columnNames,
			<<Set Function( // I don't think you want this at all,
				Function( {self}, // but here's an example.
					Match( self << Get Selected,
						"age", print("you picked age"),
						"height", print("you picked height"),
						"weight", print("you picked weight"),
						print("you picked this:",self<<get selected)
					)
				)
			)
		)
	)
);
// this is what I think you want...
show(columnNames[cl["allcolumn"]]);

<<return result is my preferred way to get the results from the dialog, after OK, and then process them.

The code that runs when a radio button is clicked usually disables/enables another part of the dialog; you might, for example, change available options when a numeric vs character variable is chosen in the radio list.

Craige
mystylelife19
Level III

Re: How to use Set Function {self}

Thankyou for reply my question,

 

Sorry i still don't understand...

 

Actually i want to have the output wafer map that shows based on my click Radio Box. Is it possible to do it?

Because i don't want to click OK everytime i choose the parameter on Radio Box. I want to make the Radio Box stay appear on my screen everytime i click OK or just using self function to see the output on wafer map. I tried to have all the column names with self function but still doesn't work.

 

How to write the self function with all the parameter i have?

 

Also how to make the Bivar Plot, Row Legend based on radio box i choose?

 

For example i want based on my images:

1. Red one is parameter on radio box i choose that make Row Legend on Bivor Plot

2. Blue one is the output i want to see based on row legend i picked on radio box

Craige_Hales
Super User

Re: How to use Set Function {self}

dt = Open( "$sample_data/big class.jmp" );

columnNames = dt << Get Column Names( "String" );

cl = New Window( "Column Selection",
//	<<modal, // optional, probably not what you want
	H List Box(
		Panel Box( "Make a selection",
			allcolumn = Radio Box(
				columnNames,
				<<Set Function(
					Function( {self},
						col = self << get selected;
						Try( (reportHolder << child) << delete ); // remove old content
						reportholder << append( dt << Distribution( Nominal Distribution( Column( Eval( col ) ) ) ) );
					)
				)
			)
		),
		reportHolder = Border Box()
	)
);
Craige
mystylelife19
Level III

Re: How to use Set Function {self}

Thankyou, it works!

 

I have one small problem my script everytime i click on radio box 5 times, it will open 5 display windows. How to make everytime i click the radio box it will change the current display windows not the open new one.

 

Can you help me to check my script...

Here below i attach the picture of my problem

//Get the current data Table
Names Default To Here( 1 );
dt = Current Data Table();

columnNames = dt << Get Column Names( "String" );

cl = New Window( "Column Selection", 
//	<<modal, // optional, probably not what you want
	H List Box(
		Panel Box( "Make a selection",
			allcolumn = Radio Box(
				columnNames,
				<<Set Function(
					Function( {self},
						col = self << get selected;
						Bivariate(
							Y( :Y ),
							X( :X ),
							By( :WAFER_ID, ),
							SendToReport(
								Dispatch(
									{},
									"Bivar Plot",
									FrameBox,
									{Row Legend(
										Eval( col ),
										Color( 1 ),
										Color Theme( "Spectral"(1) ),
										Marker( 0 ),
										Marker Theme( "" ),
										Continuous Scale( 0 ),
										Reverse Scale( 0 ),
										Excluded Rows( 0 )
									)}
								)
							)
						);
					)
				)
			)
		)
	)
);
Craige_Hales
Super User

Re: How to use Set Function {self}

This was harder to write than it looks, but turned out simpler than I expected.

dt = Open( "$sample_data/big class.jmp" );

columnNames = dt << Get Column Names( "String" );

anchorPoint = Empty(); // no previous window remembered yet

// the report to generate with col which depends on col being global.
// used below, either as Report(...) which makes a new window,
// or <<apend(...) which append to an existing box.
// write the expression once and use it in several places below...
makereport = Expr(
	dt << Distribution( Nominal Distribution( Column( Eval( col ) ) ) )
);

cl = New Window( "Column Selection",
	H List Box(
		Panel Box( "Make a selection",
			allcolumn = Radio Box(
				columnNames,
				<<Set Function(
					Function( {self},
						col = self << get selected;
						If( Is Empty( anchorPoint ),
							newReport = Report( makereport );
							anchorPoint = newReport << TopParent;
						, // else try to reuse the window if it still exists
							(anchorPoint << child) << delete; // remove old content
							anchorPoint << append( makereport ); // add new content
						);
					)
				)
			)
		)
	)
);
// force the item 1 script to run without running the item 2 script
allcolumn << set( 2, runscript( 0 ) );
allcolumn << set( 1, runscript( 1 ) );

Simpler than expected because anchorPoint becomes empty when the window is closed. I was writing several try() blocks to handle closed windows...but didn't need them. Cool! The last two lines at the end are the only way I could find to run the script for the current selection to pre-open a window.

Anyone reading along: this design might or might not violate a GUI design principle that radio buttons should select something but not perform an action. If you believe the radio button in this application is selecting a variable and showing a visual to help with the selection process, great! But if you think you are using the radio button to perform the analysis, you might be frustrating your users!

 

Craige