Choose Language Hide Translation Bar
Highlighted
tonkatsu2020
Level I

How to take function arguments from a drop down list to use the same argument in a plot

i am creating a drop down list using combo box. the idea is choosing a particular item/option from that list should create a corresponding bar plot. 

in the attached code, Tool_time_wf is the function that is supposed to create the plot by using the argument/prompt/equipment name[variable choice] from the combo box. Each item/option in the combo box myListbox is already a column name in the data table (attached) from which the bar plot should be generated as week[column 1 in the data table] vs. equipment name/column name [column 2 and onwards in the data table].

 

the user is ideally choosing a equipment name/column name  from the drop down , and the same equipment name exists as column name in the data table (see attached untitled 90 data table) that will be plotted as week vs. column name/equipment name. although the attached data table here only shows 2 column name or, 2 equipment name. but the actual table will have 100 column name/100 equipment name. SO i need a function (this is where i am stuck now) that will create the plot using the selection from drop down of 100 equipment name/column name. 

 

any help would be appreciated. best regards. 

  

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How to take function arguments from a drop down list to use the same argument in a plot

There are a few issues with your script......all minor

  1. Your New Window, which is the control part of your code, needs to be after all of the code that is going to be called.  That is, you can not call doListChoice before JMP has read doListChoice in.  JSL is an interpreter, it starts reading code on line one, and then just follows where the code takes it.  
  2. The way you had your code structured, with the New Window towards the top, meant that it was always using the code from the previous run.  JMP retains the code from run to run, unless told otherwise.  I have placed a Clear Globals() in your code to make sure everything is cleared out for each run.
  3. You were referencing the xvar and yvar improperly.  I have changed that code slightly to make it work.
  4. The code was getting confused on what data table to process.  I have added dtNames and dt to allow for the code to point to the data to make it clearer
  5. week.PNG
Clear Symbols();
Names Default To Here( 1 );

//current data table that has data on individual equipment based on each week 
filepath="C:\temp_files\jmp\tool time vs CW\#jmp-script\for jmp SAS community QA\Untitled 90.jmp";
dtNames = Open(filepath,invisible);

//equipment list (will go upto 100 [equip 1 , equip 2 ,..........equip 100], only shows 2 here for example)
filepath="C:\temp_files\jmp\tool time vs CW\#jmp-script\for jmp SAS community QA\Equipment Name-wf.jmp";
dt = Open(filepath,invisible);
//dtNames = Data Table( "Equipment Name-wf" );
//dt = Data Table( "Untitled 90 (1)" );

doListChoice = Expr(
	choice = myListbox << getSelected; // choosing the equipment name from the drop down list
	Tool_time_wf( "week", choice ); //does not work
	
);


//Tool_time_wf(week column, tool name in string quotes works);
Tool_time_wf = Function( {xvar, yvar}, 	
	bivExpr = dt << Graph Builder(
		Size( 534, 464 ),
		Show Control Panel( 0 ),
		Variables( X( Eval( xvar ) ), Y( Eval( yvar ) ) ),
		Elements( Bar( X, Y ) )
	)
);

myList = Column( Data Table( "Equipment Name-wf" ), 1 ) << Get Values;
myListbox = Combo Box( myList, doListChoice );

//@@//showing drop down -works-st
New Window( "Show List",
	Text Box(
		" Please select a TOOL/MACHINE from the drop down menu:",
		<<font color( "Blue" ),
		<<Set Font( "Arial Black" ),
		<<Set Font Size( 8 ),
		<<Set Font Style( "Regular" )
	),
	myListbox
);
Jim

View solution in original post

6 REPLIES 6
Highlighted
txnelson
Super User

Re: How to take function arguments from a drop down list to use the same argument in a plot

I need a little more help in understanding what you are trying to do. Could you produce the chart that you are expecting to display, if the user had selected, lets say "W06" from the pull down list?
Jim
Highlighted
tonkatsu2020
Level I

Re: How to take function arguments from a drop down list to use the same argument in a plot

Hello txnelson, apologies for not making the inquiry clearer.

The user should select the equipment names (equip 1 or equip 2 .....or equip 100), not week number from the dropdown list.

For the list/table that will be generating the drop down list, please see the 'Equipment Name-wf' jmp table.

Once the equipment name is selected from the pull down list (generated via the 'Equipment Name-wf'); the function should use that equipment name ; go into the main data table 'Untitled 90' (where the weekly data for the equipments are tabulated) ; and then plot the desired week vs. equip# plot as shown in the attached 'desired equip vs week plot' image file.    

 

please let me know if you have further questions/concerns. thanks for looking into this. i again uploaded the .jsl code with additional comments 'snippet v2'.

Highlighted
txnelson
Super User

Re: How to take function arguments from a drop down list to use the same argument in a plot

There are a few issues with your script......all minor

  1. Your New Window, which is the control part of your code, needs to be after all of the code that is going to be called.  That is, you can not call doListChoice before JMP has read doListChoice in.  JSL is an interpreter, it starts reading code on line one, and then just follows where the code takes it.  
  2. The way you had your code structured, with the New Window towards the top, meant that it was always using the code from the previous run.  JMP retains the code from run to run, unless told otherwise.  I have placed a Clear Globals() in your code to make sure everything is cleared out for each run.
  3. You were referencing the xvar and yvar improperly.  I have changed that code slightly to make it work.
  4. The code was getting confused on what data table to process.  I have added dtNames and dt to allow for the code to point to the data to make it clearer
  5. week.PNG
Clear Symbols();
Names Default To Here( 1 );

//current data table that has data on individual equipment based on each week 
filepath="C:\temp_files\jmp\tool time vs CW\#jmp-script\for jmp SAS community QA\Untitled 90.jmp";
dtNames = Open(filepath,invisible);

//equipment list (will go upto 100 [equip 1 , equip 2 ,..........equip 100], only shows 2 here for example)
filepath="C:\temp_files\jmp\tool time vs CW\#jmp-script\for jmp SAS community QA\Equipment Name-wf.jmp";
dt = Open(filepath,invisible);
//dtNames = Data Table( "Equipment Name-wf" );
//dt = Data Table( "Untitled 90 (1)" );

doListChoice = Expr(
	choice = myListbox << getSelected; // choosing the equipment name from the drop down list
	Tool_time_wf( "week", choice ); //does not work
	
);


//Tool_time_wf(week column, tool name in string quotes works);
Tool_time_wf = Function( {xvar, yvar}, 	
	bivExpr = dt << Graph Builder(
		Size( 534, 464 ),
		Show Control Panel( 0 ),
		Variables( X( Eval( xvar ) ), Y( Eval( yvar ) ) ),
		Elements( Bar( X, Y ) )
	)
);

myList = Column( Data Table( "Equipment Name-wf" ), 1 ) << Get Values;
myListbox = Combo Box( myList, doListChoice );

//@@//showing drop down -works-st
New Window( "Show List",
	Text Box(
		" Please select a TOOL/MACHINE from the drop down menu:",
		<<font color( "Blue" ),
		<<Set Font( "Arial Black" ),
		<<Set Font Size( 8 ),
		<<Set Font Style( "Regular" )
	),
	myListbox
);
Jim

View solution in original post

Highlighted
tonkatsu2020
Level I

Re: How to take function arguments from a drop down list to use the same argument in a plot

thank you very much txnelson. would you please also elaborate how the Tool_time_wf  function is working? I am not 100% clear on the expr and eval working principle. regards.

 

Highlighted
txnelson
Super User

Re: How to take function arguments from a drop down list to use the same argument in a plot

In the code above, Expr() is basically a holder of code, and is not processed until the pointer to the Expr() is processed in the code. The Eval() is a function that says to JMP, process the code withing the Eval() and return to JSL, the results of the code process.
Jim
Highlighted
tonkatsu2020
Level I

Re: How to take function arguments from a drop down list to use the same argument in a plot

thank you again. appreciate it.