cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
singaraveluR
Level II

how to get values from datatable and use to plot variable charts using for loop

Hi, I am new to JMP scripting. I have a data table (test data.jmp) with few columns as an example, manually I plotted the variable chart and manually I added the reference lines and then got the script from save script menu. Here I have plotted 3 columns. I have nearly 50 columns to be ploted. The only difference in each plot is the Y axis and the reference lines location. I am trying to figure how out, How to pull these data from another datatable (spec limits.jmp) and then incorporate with a For loop and plot the variable chart.  I have attached the test data, spec limit data and the script I am using. Can i get some help please.

1 ACCEPTED SOLUTION

Accepted Solutions
singaraveluR
Level II

Re: how to get values from datatable and use to plot variable charts using for loop

main = open( ); //Open test data
//open();
//main = current data table();

parameter_dt = Open( );
dt = Current Data Table();

Param_List = Column( parameter_dt, "Process") << Get Values;
LSL_spec = Column( parameter_dt, "LSL") << Get Values; 
USL_spec = Column( parameter_dt, "USL") << Get Values; 
LCL_spec = Column( parameter_dt, "LCL") << Get Values; 
UCL_spec = Column( parameter_dt, "UCL") << Get Values; 
Median_spec = Column( parameter_dt, "Median") << Get Values; 
Yinc_spec = Column( parameter_dt, "Yinc") << Get Values; 
Ymax_spec = Column( parameter_dt, "Ymax") << Get Values;
Ymin_spec = Column( parameter_dt, "Ymin") << Get Values; 

nw = New Window( "test data", container = V List Box() );

For ( i=1, i<=N items(Param_List), i++,
	content = V List Box(
		Eval(
			Substitute(
				Expr(
					main << Variability Chart(
					Y( __ParamList__ ),
					X( :Test date ),
					Show Range Bars( 0 ),
					Show Cell Means( 0 ),
					Std Dev Chart( 0 ),
					SendToReport(
						Dispatch(
							{__VarChart__},
							"2",
							ScaleBox,
							{Min( Ymin_spec[i] ), Max( Ymax_spec[i] ), Inc( Yinc_spec[i] ), Minor Ticks( 1 ),
							Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
							Add Ref Line( LSL_spec[i], "Solid", "Black", "LSL", 1 ),
							Add Ref Line( USL_spec[i], "Solid", "Black", "USL", 1 ),
							Add Ref Line( LCL_spec[i], "Solid", "Magenta", "LCL", 1 ),
							Add Ref Line( UCL_spec[i], "Solid", "Magenta", "UCL", 1 ),
							Add Ref Line( Median_spec[i], "Solid", "Magenta", "Median", 1 )}
							)
						)
					)
				),
				Expr(__ParamList__), Parse( ":" || Char(Param_List[i])),
				Expr(__VarChart__), "Variability Chart for " || Char( Param_List[i])
			)
		);
	);
	container << Append(content)
);

Hi Jim,

 

  I followed your script and found few other post and got my question solved. Here is the script I have finally.

Thanks for your help

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: how to get values from datatable and use to plot variable charts using for loop

A search of the Community Discussions finds several entries that cover the questions you are asking.  However, understanding that you are new to JMP, below is a completed script that should provide you with what you want

main << Variability Chart(
	Y( :C ),
	X( :Test date ),
	Show Range Bars( 0 ),
	Show Cell Means( 0 ),
	Std Dev Chart( 0 ),
	SendToReport(
		Dispatch(
			{"Variability Chart for C"},
			"2",
			ScaleBox,
			{Min( 0.1 ), Max( 0.106 ), Inc( 0.001 ), Minor Ticks( 1 ),
			Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
			Add Ref Line( 665, "Solid", "Black", "LSL", 1 ),
			Add Ref Line( 685, "Solid", "Black", "USL", 1 ),
			Add Ref Line( 670, "Solid", "Magenta", "LCL", 1 ),
			Add Ref Line( 680, "Solid", "Magenta", "UCL", 1 ),
			Add Ref Line( 675, "Solid", "Magenta", "Median", 1 )}
		)
	)
)
Jim
singaraveluR
Level II

Re: how to get values from datatable and use to plot variable charts using for loop

Thanks for your reply. The one you have given (helped) is to plot one chart. I have a datatable with more than 50 col, if I plot a variable chart and manually add the reference lines, adjust the Y min and Y max and then convert to script, it is okay. I was thinking if I have another datatable with all the spec like UCL, LCL, median, Ymax, etc. How to get the data from that spec datatable and add each values something like arrays and then incorporate those values in the plot. 

singaraveluR
Level II

Re: how to get values from datatable and use to plot variable charts using for loop

main = open( ); //Open test data
//open();
//main = current data table();

parameter_dt = Open( );
dt = Current Data Table();

Param_List = Column( parameter_dt, "Process") << Get Values;
LSL_spec = Column( parameter_dt, "LSL") << Get Values; 
USL_spec = Column( parameter_dt, "USL") << Get Values; 
LCL_spec = Column( parameter_dt, "LCL") << Get Values; 
UCL_spec = Column( parameter_dt, "UCL") << Get Values; 
Median_spec = Column( parameter_dt, "Median") << Get Values; 
Yinc_spec = Column( parameter_dt, "Yinc") << Get Values; 
Ymax_spec = Column( parameter_dt, "Ymax") << Get Values;
Ymin_spec = Column( parameter_dt, "Ymin") << Get Values; 

nw = New Window( "test data", container = V List Box() );

For ( i=1, i<=N items(Param_List), i++,
	content = V List Box(
		Eval(
			Substitute(
				Expr(
					main << Variability Chart(
					Y( __ParamList__ ),
					X( :Test date ),
					Show Range Bars( 0 ),
					Show Cell Means( 0 ),
					Std Dev Chart( 0 ),
					SendToReport(
						Dispatch(
							{__VarChart__},
							"2",
							ScaleBox,
							{Min( Ymin_spec[i] ), Max( Ymax_spec[i] ), Inc( Yinc_spec[i] ), Minor Ticks( 1 ),
							Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
							Add Ref Line( LSL_spec[i], "Solid", "Black", "LSL", 1 ),
							Add Ref Line( USL_spec[i], "Solid", "Black", "USL", 1 ),
							Add Ref Line( LCL_spec[i], "Solid", "Magenta", "LCL", 1 ),
							Add Ref Line( UCL_spec[i], "Solid", "Magenta", "UCL", 1 ),
							Add Ref Line( Median_spec[i], "Solid", "Magenta", "Median", 1 )}
							)
						)
					)
				),
				Expr(__ParamList__), Parse( ":" || Char(Param_List[i])),
				Expr(__VarChart__), "Variability Chart for " || Char( Param_List[i])
			)
		);
	);
	container << Append(content)
);

Hi Jim,

 

  I followed your script and found few other post and got my question solved. Here is the script I have finally.

Thanks for your help