The Remove Ref Line works fine on my system. The issue with the Revert Axis is that if anything on the axis has been changed, it will go back to the original setting when the Revert Axis is run. So if the actual axis range or increments have been changed, the revert axis moves the axis back to the original. I think the issue you were having is possibly a timing issue, so I have added in a Wait(0) which I believe might fix the issue for you. Also, you were no longer pointing to the correct charts after you added in the Weight column to the Variability Platform. After that change, the Output Display structure is changed. There are now 2 separate reporting branches.
gb[1]
and
gb[2]
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
sliderValue = 1;
dothisonchange = Function( {val},
tb << Set Text( "Cpk : " || Substr( Char( val ), 1, 4 ) )
);
Flag = 0;
Mean = 60;
wMean = 105;
wstd = 2;
std = 0.5;
LL = Mean - (sliderValue * 3 * std);
UL = Mean + (sliderValue * 3 * std);
holdLL = LL;
holdUL = UL;
wLL = wMean - (sliderValue * 3 * wstd);
wUL = wMean + (sliderValue * 3 * wstd);
wholdLL = LL;
wholdUL = UL;
New Window( "",
H List Box(
V List Box(
tb = Text Box( "Value: " || Char( sliderValue ) ),
sb = Slider Box(
1,
3,
sliderValue,
sliderValue = sb << Get;
LL = Mean - (sliderValue * 3 * std);
UL = Mean + (sliderValue * 3 * std);
wLL = wMean - (sliderValue * 3 * wstd);
wUL = wMean + (sliderValue * 3 * wstd);
//Set the slider and call the other function
sb << Set( sliderValue );
gbfb1 = Report( gb[1] )[AxisBox( 1 )];
gbfb2 = Report( gb[2] )[AxisBox( 1 )];
LL = Mean - (sliderValue * 3 * std);
UL = Mean + (sliderValue * 3 * std);
wLL = wMean - (sliderValue * 3 * wstd);
wUL = wMean + (sliderValue * 3 * wstd);
//gbfb1 << revert axis;
try(gbfb1 << remove ref line(holdLL));
try(gbfb1 << remove ref line(holdUL));
try(gbfb2 << remove ref line(wholdLL));
try(gbfb2 << remove ref line(wholdUL));
wait(0);
If( Flag == 1,
gbfb1 << add ref line( LL, Solid, red, "LL" );
gbfb1 << add ref line( UL, Solid, red, "UL" );
gbfb2 << add ref line( wLL, Solid, red, "LL" );
gbfb2 << add ref line( wUL, Solid, red, "UL" );
);
holdLL = LL;
holdUL = UL;
wholdLL = wLL;
wholdUL = wUL;
dothisonchange( sliderValue );
),
Button Box( "Add Reference line",
If( Flag == 0,
Flag = 1;
gbfb1 = Report( gb[1] )[AxisBox( 1 )];
gbfb2 = Report( gb[2] )[AxisBox( 1 )];
LL = Mean - (sliderValue * 3 * std);
UL = Mean + (sliderValue * 3 * std);
wLL = wMean - (sliderValue * 3 * wstd);
wUL = wMean + (sliderValue * 3 * wstd);
try(gbfb1 << remove ref line(holdLL));
try(gbfb1 << remove ref line(holdUL));
try(gbfb2 << remove ref line(wholdLL));
try(gbfb2 << remove ref line(wholdUL));
gbfb1 << add ref line( LL, Solid, red, "LL" );
gbfb1 << add ref line( UL, Solid, red, "UL" );
gbfb2 << add ref line( wLL, Solid, red, "LL" );
gbfb2 << add ref line( wUL, Solid, red, "UL" );
dothisonchange( sliderValue );
)
)
)
),
V List Box(
gb = dt << Variability Chart(
Y( :height, : weight ),
X( :sex ),
Show Range Bars( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 )
);
)
);
See the new code for how the change is handled.
Jim