cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
PhamBao
Level II

How can execute JSL commands after conditions is meet

Dear JMP community users,
I am a new for JMP and I have been facing a problem. Hopefully, I could get help from you guys.

I have a data  table. I would like to run a graph builder for columns only some specific values.

For instance, I would like to select cells that are AB766 and RSDF belonging columns "monitor_set_name" and "measurement_set_name" ;and other columns and rows corresponding to " AB766" and "RSDF"

PhamBao_1-1625808490392.png

Then, I would like to run " Graph builder " for the table that contains  information I need.
If "monitor_set_name" and "measurement_set_name" do not contain "AB766" and "RSDF", I will skip to run the "graph builder"

Could you give me some advice?

Sincerely,

 

10 REPLIES 10
txnelson
Super User

Re: How can execute JSL commands after conditions is meet

To generate the JSL below, I simply ran the steps interactively, and then grabbed the code from the log and pasted it into a script window.

names default to here(1);

// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );


// Select matching cells
Data Table( "big class" ) << Select Where( :age == 12 & :sex == "F" );


// Subset data table
// → Data Table( "Subset of big class" )
Data Table( "big class" ) << Subset( Selected Rows( 1 ), Selected columns only( 0 ) );


// Report snapshot: Subset of big class - Graph Builder
Data Table( "Subset of big class" ) << Graph Builder(
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

// Invert current selection
Data Table( "big class" ) << Invert Row Selection;


// Subset data table
// → Data Table( "Subset of big class 2" )
Data Table( "big class" ) << Subset( Selected Rows( 1 ), Selected columns only( 0 ) );


// Report snapshot: Subset of big class 2 - Graph Builder
Data Table( "Subset of big class 2" ) <<
Graph Builder(
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 6 ) ), Smoother( X, Y, Legend( 7 ) ) )
);
Jim
PhamBao
Level II

Re: How can execute JSL commands after conditions is meet

Dear txnelson,
It works. Appreciate a lot .
I try to follow your guidance and apply it for myself

dt = Open( "raw_data.csv", "invisible" );

dt << Select Where(
	:monitor_set_name == "CSP_FAST_TC" & :spc_chart_subset == "STDDEV" & :measurement_set_name == "U1_X"
);

df = dt << Subset( Selected Rows( 1 ), Selected columns only( 0 ), "invisible" );

df << Graph Builder(
	Size( 1056, 675 ),
	Show Control Panel( 0 ),
	Automatic Recalc( 0 ),
	Variables(
		X( :spc_txn_date ),
		Y( :chart_value ),
		Y( :lo_control_lmt, Position( 1 ) ),
		Y( :up_control_lmt, Position( 1 ) ),
		Y( :centerline, Position( 1 ) ),
		Group Y( :monitor_set_name ),
		Group Y( :measurement_set_name ),
		Group Y( :spc_chart_subset ),
		Wrap( :spc_entity )
	),
	Elements(
		Line( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 25 ), Connection( "Curve" ), Smoothness( 0.5 ) )
	),
	SendToReport(
		Dispatch( {}, "spc_txn_date", ScaleBox, {Label Row( Automatic Font Size( 0 ) )} ),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				25,
				Properties( 2, {Line Color( 19 )} ),
				Properties( 3, {Line Color( 0 ), Line Style( "Dotted" )} )
			)}
		)
	)
);

df << save picture( "C:\Users\lamquocb\image.jpg" );


However, I encounter another issue that I could not save the picture - graph builder for df. 
I try to access the location I want to store the picture, but I could not find one.
Do you have any advice?
Sincerely,

txnelson
Super User

Re: How can execute JSL commands after conditions is meet

Your variable "df" points to the subsetted data table.  When you create a report from a data table, it does not become part of the data table.  It is an entity upon itself.  Therefore the easiest way to access the created report, is to specify a variable to point to it.  I have done this in the below modification of your script.

gb = df << Graph Builder(

Variable "gb" points to the Graph Builder object.  Later in the code, the Save Picture message is applied to the report generated by the Graph Builder platform

report(gb) << save picture( "C:\Users\lamquocb\image.jpg" );

Here is the modified script

names default to here( 1 );
dt = Open( "raw_data.csv", "invisible" );

dt << Select Where(
	:monitor_set_name == "CSP_FAST_TC" & :spc_chart_subset == "STDDEV" & :measurement_set_name == "U1_X"
);

df = dt << Subset( Selected Rows( 1 ), Selected columns only( 0 ), "invisible" );

gb = df << Graph Builder(
	Size( 1056, 675 ),
	Show Control Panel( 0 ),
	Automatic Recalc( 0 ),
	Variables(
		X( :spc_txn_date ),
		Y( :chart_value ),
		Y( :lo_control_lmt, Position( 1 ) ),
		Y( :up_control_lmt, Position( 1 ) ),
		Y( :centerline, Position( 1 ) ),
		Group Y( :monitor_set_name ),
		Group Y( :measurement_set_name ),
		Group Y( :spc_chart_subset ),
		Wrap( :spc_entity )
	),
	Elements(
		Line( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 25 ), Connection( "Curve" ), Smoothness( 0.5 ) )
	),
	SendToReport(
		Dispatch( {}, "spc_txn_date", ScaleBox, {Label Row( Automatic Font Size( 0 ) )} ),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				25,
				Properties( 2, {Line Color( 19 )} ),
				Properties( 3, {Line Color( 0 ), Line Style( "Dotted" )} )
			)}
		)
	)
);

report(gb) << save picture( "C:\Users\lamquocb\image.jpg" );

I strongly recommend that you take the time to read the Scripting Guide, available in the JMP Documentation Library, found under the Help pull down menu!

Jim
PhamBao
Level II

Re: How can execute JSL commands after conditions is meet

Dear Txnelson,

It works. Thank your suggestion. I will refer the Scripting Guide for study.

Meanwhile, I have on more question.  


I would like to extract value from cell of the column, then assign the value to variables since I would like to use variables for graphing.

 

However, in case my table does not contain column :lo_control_lmt@u2_holdforceduration_2 or  :up_control_lmt@u2_holdforceduration_2 , my script does not show any graph

If I delete 2 lines in the my script below, my script will show the graph

U2_UCL_HDF = Column(dt,"up_control_lmt@u2_holdforceduration_2")[1];

U2_LCL_HDF = Column(dt,"lo_control_lmt@u2_holdforceduration_2")[1];

 

Do have any solution for this case. Sincerely.

 

My script:

U1_UCL_HDF = Column( dt, "up_control_lmt@u1_holdforceduration_2" )[1]; //extract value from cell
U1_LCL_HDF = Column( dt, "lo_control_lmt@u1_holdforceduration_2" )[1]; //extract value from cell
U2_UCL_HDF = Column( dt, "up_control_lmt@u2_holdforceduration_2" )[1]; //extract value from cell
U2_LCL_HDF = Column( dt, "lo_control_lmt@u2_holdforceduration_2" )[1];   // extract value from cell

 

 

NW = New Window( "KPP summarize",
	Variability Chart(
		Y( :HOLDFORCEDURATION_2 ),
		X( :COMPLEVEL_1, :LINK_ID, :TEST_OR_BOND_HEAD_ID, :LOT, :BONDSTAGE, :CARRIER_X ),
		Max Iter( 100 ),
		Conv Limit( 0.00000001 ),
		Number Integration Abscissas( 128 ),
		Number Function Evals( 65536 ),
		Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
		Connect Cell Means( 1 ),
		Std Dev Chart( 0 ),
		Points Jittered( 1 ),
		AIAG Labels( 0 ),
		SendToReport(
			Dispatch(
				{"Variability Chart for HOLDFORCEDURATION_2"},
				"2",
				ScaleBox,
				{Min( 332 ), Max( 641 ), Inc( 50 ), Minor Ticks( 1 ),
				Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
				Add Ref Line( U1_UCL_HDF, "Solid", "Red", "UCL_U1", 2 ), 

				Add Ref Line( U1_LCL_HDF, "Solid", "Red", "LCL_U1", 2 ), // put the value in here extract
				Add Ref Line( U1_CT_HDF, "DashDot", "Red", "CL_U1", 2 ), // put the value in here extract
				Add Ref Line( U2_UCL_HDF, "Solid", "BlueCyan", "UCL_U2", 2 ), // put the value in here extract
				Add Ref Line( U2_LCL_HDF, "Solid", "BlueCyan", "LCL_U2", 2 ), // put the value in here extract
				Add Ref Line( U2_CT_HDF, "DashDot", "BlueCyan", "CL_U2", 2 )}  // put the value in here extract
			)
		)
	)
);
txnelson
Super User

Re: How can execute JSL commands after conditions is meet

I am confused.  You indicate that you want to read values from a specified column, cell 1, but that you do not have such a column.

JMP will stop running when it can not find a referenced column.  Therefore, it will not continue processing once the error is found.

If you don't have such a column and you want to have it, you will need to add the column to the data table, and populate cell 1 with the value you want it to have.  That is the solution.......but I don't think I am really understanding the question.

Jim
PhamBao
Level II

Re: How can execute JSL commands after conditions is meet

Dear txnelson,

JMP will stop running when it can not find a referenced column --> you are correct

 

I would like to clarify my question. Thing is I try to get data from the system in my company. Because of different product categories, the data table will be different.
For example:

Product A: contain column  :up_control_lmt@u1_holdforceduration_2 and up_control_lmt@u2_holdforceduration_2
Product B: only contain column :up_control_lmt@u1_holdforceduration_2 

Since I want to build a script that can be applied for both products.

In you suggestion, I need to add one more column for product B if  data table of product B does not contain column :up_control_lmt@u2_holdforceduration_2.

Therefore, with function that I can use to check whether data table of product B contain or not :up_control_lmt@u2_holdforceduration_2.--> if the data table does contain :up_control_lmt@u2_holdforceduration_2., I will add new column to the data table.

Hopefully, you could understand my question ?

Sincerely,

txnelson
Super User

Re: How can execute JSL commands after conditions is meet

The Try() function is one way of dealing with this.

U1_UCL_HDF =Try( Column( dt, "up_control_lmt@u1_holdforceduration_2" )[1],.);

if(isMissing(:U1_UCL_HDF),
     add and populate the new column
);

U1_UCL_HDF will have a valid value if the column and row exists, but if the attempt fails, it will return a missing value.  therefore the flow could be something like

Jim
PhamBao
Level II

Re: How can execute JSL commands after conditions is meet

Let I try it Thank you a lot.

By the way, I found one method  that has been suggested in the forum and it works for me

CHECK_U2_CT_HDF = Contains(
    df << get column names( string ),
    "centerline@u2_holdforceduration_2"
);

If( CHECK_U2_CT_HDF == 0,
    df << New Column( "centerline@u2_holdforceduration_2",
        Numeric,
        Continuous,
        Format( "Best", 10 )
    )
);



Thank for your strong support!

Re: How can execute JSL commands after conditions is meet

Hi,

 

If you are new to JMP, be sure to check out the Local Data Filter and Column Switcher. The local data filter will likely help you here... I included a column switcher in my example just to let you know what it can do.

 

Just click on the menu items to restrict your graph to the data you wish to consider. No coding is required, and it is easy to use... anyone can use these.

 

To get the Local Data Filter, from Graph Builder's red triangle menu select Add Local Data Filter.

 

To get the Column Switcher, select Redo > Column Switcher from the main menu. You'll also have to select the column you want to swap out, and the columns you'd like to rotate among. Be sure to include the column you want to swap out, in this set. All columns must be of the same data type.

 

Run the script below to get a glimpse of these in action.

 

Cheers,

Brady

 

brady_brady_0-1625853552268.png

Names Default To Here(1);

dt = open ("$Sample_Data\Car Physical Data.jmp");

Graph Builder(
	Size( 526, 448 ),
	Show Control Panel( 0 ),
	Variables( X( :Country ), Y( :Gas Tank Size ) ),
	Elements( Box Plot( X, Y, Legend( 8 ) ), Points( X, Y, Legend( 9 ) ) ),
	Local Data Filter(
		Show Histograms and Bars( 0 ),
		Add Filter(
			columns( :Type ),
			Where( :Type == "Compact" ),
			Display( :Type, N Items( 5 ) )
		)
	),
	Column Switcher(
		:Gas Tank Size,
		{:Weight, :Turning Circle, :Displacement, :Horsepower, :Gas Tank Size}
	)
);