By setting the RowState color to red for the rows where there are Max values, the displayed labels for those rows will be red. I have added some code to the current script to handle the coloring.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt:name << set labelled( 0 ); // Remove the default label
// Create the new row column
dt << New Column( "row", formula( Row() ) );
dt << run formulas;
Column( "row" ) << deleteFormula;
// Add the first label column
dt << New Column( "max", character,
Formula(
If( height == Max( height[Index( Row() - 5, Row() + 5 )] ),
name
)
)
);
dt << run formulas;
Column( "max" ) << deleteFormula;
Column( "max" ) << set labelled( 1 );
dt << select where( :max != "" );
selectedRows = dt << get selected rows;
for(i=1,i<=NRows(selectedRows),i++,
rowstate( selectedRows[i] ) = Color State ("red")
);
dt<<select where(:max !="");
dt << Label;
dt << clear select;
// Run the graph
c1 = Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :row ), Y( :height ) ),
Elements( Line( X, Y, Legend( 5 ) ), Points( X, Y, Legend( 6 ) ) )
);
Report( c1 )[framebox( 1 )] << Marker Size( 0 );
// Wait added to allow initial labeling before adding new labeling
Wait( 5 );
// Add new label column
dt << New Column( "min", character,
Formula(
If( height == Min( height[Index( Row() - 5, Row() + 5 )] ),
name
)
)
);
dt << run formulas;
Column( "min" ) << deleteFormula;
Column( "min" ) << set labelled( 1 );
dt << select labeled;
dt << select where( :min != "", current selection( "extend" ) );
dt << Label;
dt << clear select;
Jim