Choose Language Hide Translation Bar
Spec Limit Lines on Graphs

Some quick notes on adding spec limit lines to all the columns in a table with spec limits When specification limits are defined in the properties of a column, it is often convenient to have the spec limits drawn as reference lines on the graphs for that column.   In the column properties for Spec Limits, there is a check box that will cause the specification for that column to be used anytime the column is used on a graph. One might want to check that little box on a whole raft of columns that have specifications. Manually this would be tedious so here is a little bit of JSL to accomplish this this task.

``````collist=dt<<get column names( Continuous );
for (i =1 , i<=nitems(collist), i++,
a=collist[i]<<get property("Spec Limits");
y=expr(show limits(1));
insert into(a, nameexpr(y));
show(a);
nn=narg(a);
aa={};
for(ii=1,ii<=nn,ii++,insert into(aa,arg(a,ii)));show(aa);
collist[i]<< Delete Property( "Spec Limits" );
collist[i]<<set property("Spec Limits", eval(aa)),
collist[i]<<set property("Spec Limits", eval(a))
));``````

The script collects a list of columns that are continuous. (character and nominal columns wouldn't have specs anyway.)

The script gets the Spec Limits column property from each column column in the list. The function, Get Column Properties, gets all the properties, but that's not what we want here so we pull just the spec limit property. If there is no Spec Limit property, then Empty() is returned. Next the script inserts y, which is an unevaluated expression containing "show limits(1)" into the list that came from the Spec Limits property. Finally the script sets the new Spec Limit property back to the column it started with... unless the Spec Limit property is an expression rather than a list.

Issues with Types of column properties?

There are two ways to have a column property set up

1. As an expression:

col<<Set Property( "Spec Limits", Spec Limits( LSL( 10 ), USL( 50 ), Target( 30 ) ) );

2.  As a list:

col<<Set Property( "Spec Limits", {LSL( 10 ), USL( 50 ), Target( 30 )} );

A bit of explanation: This part of the script...

nn=narg(a);

aa={};

for(ii=1,ii<=nn,ii++,insert into(aa,arg(a,ii)));show(aa);

collist[i]<< Delete Property( "Spec Limits" );

collist[i]<<set property("Spec Limits", eval(aa))

...checks to see if the specification property is the expression type. Then inserts the components of the argument into a list. After deleting the existing property, the new list type property is added back.

This is the script to standarized the specification column property type

``````dt=current data table();
collist=dt<<get column names( Continuous );
for (i =1 , i<=nitems(collist), i++,
a=collist[i]<<get property("Spec Limits");
y=expr(show limits(1));
insert into(a, nameexpr(y));
show(a);
nn=narg(a);
aa={};
for(ii=1,ii<=nn,ii++,insert into(aa,arg(a,ii)));show(aa);
collist[i]<< Delete Property( "Spec Limits" );
collist[i]<<set property("Spec Limits", eval(aa)),
collist[i]<<set property("Spec Limits", eval(a))
));``````

For testing: This is a reduced test case to use as an example. This bit of JSL makes a new table with the two different types of spec property formats.

``````dt=New Table( "target", Add Rows( 1 ), New Column( "a-b", Numeric, "Continuous", Format( "Best", 12 ), Set Values(  ) ),
New Column( "b minus a",Numeric, "Continuous", Format( "Best", 12 ), Set Selected,Set Values(  )));
//Add both formats of specification limits
:column(1)<<Set Property( "Spec Limits", Spec Limits( LSL( 10 ), USL( 50 ), Target( 30 ) ) );
:column(2)<<Set Property( "Spec Limits", {LSL( 1 ), USL( 5 ), Target( 3 )} );
aa= :column(1)<<get property("Spec Limits");show(aa);
bb= :column(2)<<get property("Spec Limits");show(bb);``````