Very nice Jim!
I took the liberty of adding to your code so that there is a separate graphics script for each annotation:
This makes it possible to move the annotations 'by hand' to avoid any collisions (Right-click on the graphics box, select 'Customize' and edit the x and y values in the scripts to taste).
Names Default To Here( 1 );
// Open the sample data table
dt = Open( "$SAMPLE_DATA\Quality Control\Pickles.jmp" );
// There isn't an adequate column to be used as a Phase column in the sample
// data table, so create one
dt << New Column( "MyPhase", character, formula( Char( Floor( Row() / 13 + 1 ) ) ) );
// Run the control Chart
ct = dt << Control Chart(
Phase( :MyPhase ),
Group Size( 1 ),
KSigma( 3 ),
Chart Col( :Acid, Individual Measurement( Phase Level( "1" ), Phase Level( "2" ) ), Moving Range( Phase Level( "1" ), Phase Level( "2" ) ) )
);
// Create a list called byPhase of the each of the Phase values
Summarize( dt, byPhase = by( :MyPhase ) );
// Find the max row for each phase to determine the X position on the chart
// for the placement of the text values
PhaseMaxRowList = {};
For( i = 1, i <= N Items( byPhase ), i++,
Insert Into( PhaseMaxRowList, Max( dt << get rows where( :MyPhase == byPhase[i] ) ) )
);
// Add the text to the chart
framebox = Report( ct )[frame box( 1 )];
addTxt = Expr(
framebox << Add Graphics Script(
Description( scriptNameTBD ),
Text Color( "Black" );
Text( Center Justified, {xTBD - 2, yTBD + .1}, txtTBD );
);
);
// Loop across the phases and add the 3 text values by pulling their values from the table
// and reformating the values
For( i = 1, i <= N Items( byPhase ), i++,
LCL = (Report( ct )["Individual Measurement of Acid"][Number Col Box( i )] << get)[1];
LCLtxt = "LCL=" || Format( LCL, "Fixed Dec", 5, 2 );
Avg = (Report( ct )["Individual Measurement of Acid"][Number Col Box( i + N Items( byPhase ) )] << get)[1];
Avgtxt = "Avg=" || Format( Avg, "Fixed Dec", 5, 2 );
UCL = (Report( ct )["Individual Measurement of Acid"][Number Col Box( i + (N Items( byPhase ) * 2) )] << get)[1];
UCLtxt = "UCL=" || Format( UCL, "Fixed Dec", 5, 2 );
// Use a separate graphics script for each annotation so that they are more easily moved 'by hand'
Eval(Substitute(NameExpr(addTxt), Expr(scriptNameTBD), "LCL Text "||Char(i), Expr(xTBD), PhaseMaxRowList[i], Expr(yTBD), LCL, Expr(txtTBD), LCLtxt));
Eval(Substitute(NameExpr(addTxt), Expr(scriptNameTBD), "Avg Text "||Char(i), Expr(xTBD), PhaseMaxRowList[i], Expr(yTBD), Avg, Expr(txtTBD), Avgtxt));
Eval(Substitute(NameExpr(addTxt), Expr(scriptNameTBD), "UCL Text "||Char(i), Expr(xTBD), PhaseMaxRowList[i], Expr(yTBD), UCL, Expr(txtTBD), UCLtxt));
);