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
newbie_4
Level II

different spec limits on a variability chart

Hello,

 

I am creating separate variability chart by OVL_UDL and PARAMETER_NAME with four X variables. I do this by script with a for loop. I want to be able to show the spec value on the charts value of which is contained in the same data table. However, I have different limit within each graph (by variable Loop) and also between chart to chart (by OVL_UDL and PARAMETER_NAME). I have looked through the forum but couldn't really come up with a way to do this using JSL.

 

<JSL>

overunder = Associative Array( dt:OVL_UDL << Get Values ) << Get Keys;

For( i = 1, i <= N Items( overunder ), i++,
	win = New Window( "window",
		var = dt2 << Variability Chart(
			Y( :VALUE ),
			X( :ROUTE, :OPERATION, :PRODUCT, :ANALYTICAL_ENTITY, :DATA_COLLECTION_TIME ),
			Connect Cell Means( 1 ),
			Std Dev Chart( 0 ),
			Points Jittered( 1 ),
			AIAG Labels( 0 ),
			Where( :OVL_UDL == overunder[i] ),
			By( :PARAMETER, :OVL_UDL ),
			SendToReport(
				Dispatch(
					{"Variability Chart for VALUE"},
					"Variability Chart",
					FrameBox,
					{Row Legend(
						:Current Layer Scanner,
						Color( 1 ),
						Color Theme( "JMP Default" ),
						Marker( 0 ),
						Marker Theme( "" ),
						Continuous Scale( 0 ),
						Reverse Scale( 0 ),
						Excluded Rows( 0 )
					), Row Legend(
						ALT,
						Color( 0 ),
						Color Theme( "" ),
						Marker( 1 ),
						Marker Theme( "Solid" ),
						Continuous Scale( 0 ),
						Reverse Scale( 0 ),
						Excluded Rows( 0 )
					)}
				)
			)
		)
	)
);

win << save picture;

 

newbie_4_0-1667594015973.png

 

4 REPLIES 4
jthi
Super User

Re: different spec limits on a variability chart

This can be done most likely much easier with graph builder than with variability chart, but if you want to use variability chart below is oversimplified example using graphic scripts

Names Default To Here(1);

dt = Open("$DOWNLOADS/test.jmp");
dt << Delete Rows(Loc(dt[0, "OVL_UDL"], "BC1_BM3"));

var = Variability Chart(
	Y(:VALUE),
	X(:Loop, :OPERATION, :ANALYTICAL_ENTITY, :DATA_COLLECTION_TIME)
);

spec_table = dt << Summary(
	Group(:Loop),
	// N Categories(:UP_CONTROL_LMT), // could be used for sanity check
	Min(:UP_CONTROL_LMT),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	Link to original data table(0),
	invisible,
	output table("spectable")
);
specs = Associative Array(Column(spec_table, "Loop"), Column(spec_table, "UP_CONTROL_LMT"));

groups = dt << Summary(
	Group(Loop, :OPERATION, :ANALYTICAL_ENTITY, :DATA_COLLECTION_TIME),
	statistics column name format("column"),
	Link to original data table(0),
	invisible,
	output table("groups")
);
fl_groups = N Rows(Loc(groups[0, "Loop"], "FL"));
sl_groups = N Rows(Loc(groups[0, "Loop"], "FL"));

framebox = Report(var)[frame box(1)];
framebox << Add Graphics Script(
	Pen Color("Blue");
	Pen Size(1);
	H Line(0, fl_groups, specs["FL"]);
	H Line(fl_groups, fl_groups + sl_groups, specs["SL"]);
);

framebox << Y Axis(Max(15));

jthi_0-1667635968670.png

 

-Jarmo
newbie_4
Level II

Re: different spec limits on a variability chart

Thanks so much. I think it works perfectly except one thing. I see that you kept only one OVL_UDL value and created only one variability chart. I want a separate chart to be created for each OVL_UDL variable. In the data, there should be on for BC1_BM3 (which you have) but one more chart for BC2_BM3. I tried putting a for loop to iterate your script for each OVL_UDL but couldn't get limits to show. Any idea how we can achieve that? 

 

Thanks

jthi
Super User

Re: different spec limits on a variability chart

Looping should work just fine, but you have to use correct limits and group sizes for each of the charts. Below is quick and dirty example (I would definitely clean this code up a lot but it should work as some sort of a starting point).

 

View more...
Names Default To Here(1);

dt = Open("$DOWNLOADS/test.jmp");

dt << New Column("PARAMETER", Character, Nominal, << Set Each Value(
	:PARAMETER_NAME || :OVL_UDL
));

dt_summary = dt << Summary(
	Group(:PARAMETER, :Loop),
	Min(:UP_CONTROL_LMT),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	Link to original data table(0)
);

dt_groups = dt << Summary(
	Group(:Loop, :PARAMETER, :OPERATION, :ANALYTICAL_ENTITY, :DATA_COLLECTION_TIME),
	statistics column name format("column"),
	Link to original data table(0),
	output table("groups")
);

nw = New Window("",
	vlb = V List Box()
);

Summarize(dt_groups, lg = By(:PARAMETER, :Loop), lg_c = Count());

For Each({param}, Associative Array(Column(dt, "PARAMETER")) << get keys,
	var_expr = EvalExpr(var = dt << Variability Chart(
		Y(:VALUE),
		X(:Loop, :OPERATION, :ANALYTICAL_ENTITY, :DATA_COLLECTION_TIME),
		Where(:PARAMETER == Expr(param))
	));
	vlb << Append(Eval(var_expr));
	
	param_idx = Loc(lg[1], param);
	param_loops = lg[2][param_idx];
	param_loop_counts = lg_c[param_idx];
	framebox = Report(var)[frame box(1)];
	end_idx = 1;
	start = 0;
	end = param_loop_counts[end_idx];
	max_limit = Report(var)[axisbox(1)] << get max;
		
	For Each({cur_loop}, param_loops,
		limit_row = dt_summary << Get Rows Where(:PARAMETER == param & :Loop == cur_loop);
		limit = dt_summary[limit_row, "UP_CONTROL_LMT"][1];
		Eval(EvalExpr(
			framebox << Add Graphics Script(
				Pen Color("Blue");
				Pen Size(1);
				H Line(Expr(start), Expr(end), Expr(limit));
			);
		));
		If(limit > max_limit,
			max_limit = limit + 0.5;
		);
		Try(
			start = end;
			end_idx++;
			end = param_loop_counts[end_idx] + start;
		);
	);
	framebox << Y Axis(Max(max_limit));
);

Close(dt_summary, no save);
Close(dt_groups, no save);

 

(variability Chart could also be created by using By option, but it will require a bit different kind of looping as you would most likely loop over variability charts and not over parameters).

-Jarmo
newbie_4
Level II

Re: different spec limits on a variability chart

Thanks. Somehow when it iterates through the OVL_UDL, it only keep correct limits on last graph. I am thinking if I can write the script to split the table into multiple tables (one for eqach OVL_UDL) and run the script through each table. How can I write a script to open one file at a time, run the plotting script, open next file and run same script again.