Here is a script that does what you want....assuming that what you want is for the colors to be displayed on chart. If you want the colors to be displayed in the data table, and what you are requesting is that the Cell Colors to be colored based upon your specification, then that would be a little different.
Names Default To Here( 1 );
// Open the Semiconductor Capability sample data table since it
// contains spec limits
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// Create a new column to setup the groupings in
dt << New Column( "Color Groupings",
Modeling Type( Nominal ),
formula(
USL = (dt:PNP3 << get property( "Spec Limits" ))["USL"];
LSL = (dt:PNP3 << get property( "Spec Limits" ))["LSL"];
If(
LSL <= dt:PNP3 <= USL, 1,
(LSL - .1 * (USL - LSL)) <= dt:PNP3 < LSL, 2,
(LSL - .2 * (USL - LSL)) <= dt:PNP3 < (LSL - .1 * (USL - LSL)), 3,
dt:PNP3 > USL, 4
);
)
);
// Add the color options
dt:Color Groupings << set property( "Value Colors", {1 = "Green", 2 = "Yellow", 3 = "Red", 4 = "Blue"} );
// Copy the value colors to the rowstates, so the platforms will
// use the colors
dt << Color by Column( Color Groupings );
// Get rid of the new column since it's use is no longer needed
dt << delete columns( "Color Groupings" );
// Show a chart using the new color options
dt << Control Chart Builder(
Size( 534, 453 ),
Show Control Panel( 0 ),
Variables( Y( :PNP3 ) ),
Chart( Position( 1 ), Limits ),
Chart( Position( 2 ) ),
SendToReport(
Dispatch(
{},
"PNP3",
ScaleBox,
{Add Ref Line( 118.677820430348, "Solid", "Blue", "LSL", 1 ), Add Ref Line(
141.901766142544,
"Solid",
"Blue",
"USL",
1
), Add Ref Line( 130.289793286446, "Solid", "Blue", "Target", 1 )}
)
)
);
Jim