Add unique SPEC limits to graph builder for each user selection of parametersHi
I wrote a script to view an interactive chart with graph builder, with user choice of selection of two parameters (MODULE_MONITOR and CHART_TYPE).
each parameters has two selection options.
Each of the four option of chart display has unique set of SPEC limits (in column): CENTERLINE, UCL, LCL.
I would like that each graph would plot the relevant SPEC limits.
Thanks!
JSL script:
Graph Builder(
Size( 866, 897 ),
Show Control Panel( 0 ),
Variables( X( :PROCESS_DATE ), Y( :VALUE ), Overlay( :group ) ),
Elements( Points( X, Y, Legend( 7 ) ), Smoother( X, Y, Legend( 9 ) ) ),
Local Data Filter(
Add Filter(
columns( :MODULE_MONITOR, :CHART_TYPE ),
Where( :MODULE_MONITOR == "PLPN" ),
Where( :CHART_TYPE == "SIGMA" )
)
),
SendToReport(
Dispatch(
{},
"VALUE",
ScaleBox,
{Add Ref Line( :UCL, "Solid", "Red", "UCL", 1 ),
Add Ref Line( :LCL, "Solid", "Red", "LCL", 1 ),
Add Ref Line( :CENTERLINE, "Solid", "Black", "CENTERLINE", 1 )
}
)
)
)
AnalyticsData TableScriptingRe: Add unique SPEC limits to graph builder for each user selection of parametersHere is an example of one way to handle your issue
Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );
gb = dt << Graph Builder(
Size( 866, 897 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ) ),
Elements( Points( X, Y, Legend( 7 ) ), Smoother( X, Y, Legend( 9 ) ) )
);
ldf = gb << Local Data Filter( Add Filter( columns( :sex ), Where( :sex == "F" ) ) );
Report( gb )[FrameBox( 1 )] << add graphics script(
wc = ldf << get where clause;
Eval( Parse( "dt << " || wc ) );
Try( Report( gb )[AxisBox( 2 )] << add Ref Line( UC, "Solid", "Blue", "", 0 ) );
Try( Report( gb )[AxisBox( 2 )] << remove Ref Line( LC, "Solid", "Blue", "", 0 ) );
Try( Report( gb )[AxisBox( 2 )] << remove Ref Line( cLINE, "Solid", "Blue", "", 0 ) );
cline = Try( dt:centerline[(dt << get selected rows)[1]], . );
uc = Try( dt:ucl[(dt << get selected rows)[1]], . );
lc = Try( dt:lcl[(dt << get selected rows)[1]], . );
Report( gb )[AxisBox( 2 )] << Add Ref Line( UC, "Solid", "Red", "UCL", 1 );
Report( gb )[AxisBox( 2 )] << Add Ref Line( LC, "Solid", "Red", "LCL", 1 );
Report( gb )[AxisBox( 2 )] << Add Ref Line( cLINE, "Solid", "Black", "CENTERLINE", 1 );
);
The attached data table contains a sample data table that I think is similar to what your table is
Re: Add unique SPEC limits to graph builder for each user selection of parametersHi
Thanks for replying
I tried to match my script to your help, but it does not work.
Script and table attached here
Hope you can help
Tomer
Names default to here (1);
dt = Current Data Table(); // Assuming the data table is open
gb = Graph Builder(
Size( 866, 897 ),
Show Control Panel( 0 ),
Variables( X( :PROCESS_DATE ), Y( :VALUE ), Overlay( :group ) ),
Elements( Points( X, Y, Legend( 7 ) ), Smoother( X, Y, Legend( 9 ) ) ),
Local Data Filter(
Add Filter(
columns( :MODULE_MONITOR, :CHART_TYPE ),
Where( :MODULE_MONITOR == "PLPN" ),
Where( :CHART_TYPE == "SIGMA" )
)
),
);
ldf = gb << Local Data Filter( Add Filter( columns( :MODULE_MONITOR, :CHART_TYPE ), Where( :MODULE_MONITOR == "PLPN" ),Where( :CHART_TYPE == "SIGMA" ) ) );
Report( gb )[FrameBox( 1 )] << add graphics script(
wc = ldf << get where clause;
Eval( Parse( "dt << " || wc ) );
Try( Report( gb )[AxisBox( 2 )] << add Ref Line( UCl, "Solid", "Blue", "", 0 ) );
Try( Report( gb )[AxisBox( 2 )] << remove Ref Line( LCl, "Solid", "Blue", "", 0 ) );
Try( Report( gb )[AxisBox( 2 )] << remove Ref Line( CENTERLINE, "Solid", "Blue", "", 0 ) );
cline = Try( dt:CENTERLINE[(dt << get selected rows)[1]], . );
uc = Try( dt:UCL[(dt << get selected rows)[1]], . );
lc = Try( dt:LCL[(dt << get selected rows)[1]], . );
Report( gb )[AxisBox( 2 )] << Add Ref Line( UC, "Solid", "Red", "UCL", 1 );
Report( gb )[AxisBox( 2 )] << Add Ref Line( LC, "Solid", "Red", "LCL", 1 );
Report( gb )[AxisBox( 2 )] << Add Ref Line( cLINE, "Solid", "Black", "CENTERLINE", 1 );
);
Re: Add unique SPEC limits to graph builder for each user selection of parametersThere were a couple of issues in the code.
- You had left in the Local Data Filter code in the body of the Graph Builder. The modification I had sent removed that code and replace it using a
ldf = gb << Local Data Filter(..........
The inclusion of both filter references forced the second one to not work properly.
- I had left two wrong references in
Try( Report( gb )[AxisBox( 2 )] << remove Ref Line( LC, "Solid", "Blue", "", 0 ) );
There is a bug in the Remove Ref Line. So rather than removing the line, the line needs to be set to line width of 0, so the line needs to read
Try( Report( gb )[AxisBox( 2 )] << add Ref Line( LC, "Solid", "Blue", "", 0 ) );
After those changes the script worked fine for me with your data.
Names default to here (1);
dt = Current Data Table(); // Assuming the data table is open
gb = Graph Builder(
Size( 866, 897 ),
Show Control Panel( 0 ),
Variables( X( :PROCESS_DATE ), Y( :VALUE ), Overlay( :group ) ),
Elements( Points( X, Y, Legend( 7 ) ), Smoother( X, Y, Legend( 9 ) ) )/*,
Local Data Filter(
Add Filter(
columns( :MODULE_MONITOR, :CHART_TYPE ),
Where( :MODULE_MONITOR == "PLPN" ),
Where( :CHART_TYPE == "SIGMA" )
)
),*/
);
ldf = gb << Local Data Filter( Add Filter( columns( :MODULE_MONITOR, :CHART_TYPE ), Where( :MODULE_MONITOR == "PLPN" ),Where( :CHART_TYPE == "SIGMA" ) ) );
Report( gb )[FrameBox( 1 )] << add graphics script(
wc = ldf << get where clause;
Eval( Parse( "dt << " || wc ) );
Try( Report( gb )[AxisBox( 2 )] << add Ref Line( UC, "Solid", "Blue", "", 0 ) );
Try( Report( gb )[AxisBox( 2 )] << add Ref Line( LC, "Solid", "Blue", "", 0 ) );
Try( Report( gb )[AxisBox( 2 )] << add Ref Line( cLine, "Solid", "Blue", "", 0 ) );
cline = Try( dt:CENTERLINE[(dt << get selected rows)[1]], . );
uc = Try( dt:UCL[(dt << get selected rows)[1]], . );
lc = Try( dt:LCL[(dt << get selected rows)[1]], . );
Report( gb )[AxisBox( 2 )] << Add Ref Line( UC, "Solid", "Red", "UCL", 1 );
Report( gb )[AxisBox( 2 )] << Add Ref Line( LC, "Solid", "Red", "LCL", 1 );
Report( gb )[AxisBox( 2 )] << Add Ref Line( cLINE, "Solid", "Black", "CENTERLINE", 1 );
);
Re: Add unique SPEC limits to graph builder for each user selection of parametersThanks. working!
Can you please explain why using
Try( Report( gb )[AxisBox( 2 )] << add Ref Line
and then
Report( gb )[AxisBox( 2 )] << Add Ref Line( UC, "Solid", "Red", "UCL", 1 );
for the UCL,CLINE, LCL?
Tomer