Here is an example where an existing limits table is used to create the reference lines. There are 2 different examples using 2 different methods
Names Default To Here( 1 );
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
// open a limits table created from Manage Limits
dtLimit = New Table( "Limits",
Add Rows( 2 ),
New Column( "Variable", Character, "Nominal", Set Values( {"height", "weight"} ) ),
New Column( "LSL", Set Values( [55, 65] ) ),
New Column( "USL", Set Values( [66, 170] ) ),
New Column( "Target", Set Selected, Set Values( [., .] ) )
);
// One way to set the reference lines
colNames = dt << get column names( string, continuous );
// Create the graphs
For Each( {col}, colNames,
gb = dt << Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( As Column( col ) ) ),
Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
// Set the ref lines
// Get the row in the limits table that has the limits for the current column
theRow = (dtLimit << get rows where( dtLimit:Variable == col ))[1];
Report( gb )[AxisBox( 2 )] << add ref line(
dtLimit:LSL[theRow],
"Solid",
"Blue",
Char( dtLimit:LSL[theRow] ),
1
);
Report( gb )[AxisBox( 2 )] << add ref line(
dtLimit:USL[theRow],
"Solid",
"Blue",
Char( dtLimit:USL[theRow] ),
1
);
);
// Second way to set the reference lines using Spec Limits column property
// the default when using the Spec Limits is for graph builder to insure
// the spec limits are displayed on the graph. This example with use the
// spec limits, and then change the label to a numeric
colNames = dt << get column names( string, continuous );
ml = dt << Manage Limits( Process Variables( Eval( colNames ) ) );
ml << load from limits table( dtLimit );
ml << Show Limits All;
ml << Save to Column Properties;
ml << Close Window;
// Create the graphs
For Each( {col}, colNames,
gb = dt << Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( As Column( col ) ) ),
Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
// Set the ref lines
// Get the limits from the spec limits for the current column
// and change the label
specs = Column( dt, col ) << get property( spec limits );
Report( gb )[AxisBox( 2 )] << add ref line( specs["LSL"], "Solid", "Blue", Char( specs["LSL"] ), 1 );
Report( gb )[AxisBox( 2 )] << add ref line( specs["USL"], "Solid", "Blue", Char( specs["USL"] ), 1 );
);
Jim