This can be done with a Filter Change handler:
dt = current data table();
gb = dt << Graph Builder(
Size( 707, 814 ),
Variables( X( :Date ), X( :Day of Week, Position( 1 ) ), Y( :FP Rate ) ),
Elements(
Line( X( 1 ), X( 2 ), Y, Legend( 4 ) ),
Points( X( 1 ), X( 2 ), Y, Legend( 5 ) )
)
);
ldf = gb << Local Data Filter(
Add Filter( columns( :Model Type ), Where( :Model Type == "B" ) )
);
f = function ({a},myrows =ldf << Get Filtered Rows;
myData =dt [myrows, "FP Rate"];
myMean = mean(myData);
mystdDev = std dev (myData);
y1 = myMean - 2 * mystdDev;
y2 = myMean + 2 * mystdDev;
// remove old ref lines
Eval(Eval Expr(report(gb)[AxisBox(2)] <<Remove Ref Line( Expr(Eval List({0, y1 old})))));
Eval(Eval Expr(report(gb)[AxisBox(2)] <<Remove Ref Line( Expr(Eval List({y1 old, y2 old})))));
Eval(Eval Expr(report(gb)[AxisBox(2)] <<Remove Ref Line( Expr(Eval List({y2 old,1})))));
// add new ref lines
report(gb)[AxisBox(2)] << {Add Ref Line( {0, y1}, "Solid", "Light Yellow", "", 1, 0.25 ),
Add Ref Line( {y1, y2}, "Solid", "Green", "", 1, 0.25 ),
Add Ref Line( {y2, 1}, "Solid", "Light Yellow", "", 1, 0.25 )
};
y1 old = y1;
y2 old = y2;
);
// gets trigger if user changes the selection
x = ldf << Make Filter Change Handler(f);