I am trying to build a custom report for viewing various data that compares the defect density from various tools. I can sometimes have many (more than 20) tools to display, causing confusion with the spline fits. I found a way to emphasize the spline when the tool is selected via the legend, but the function causes intermittent crashes on JMP.
Here is a script that can reproduce the error, but it is intermittent -- simply select various elements of the legend, and also deselect all elements using <CTRL>
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
dt << Color or Mark by Column( "Gender" );
change_lines = Function( {table, ns},
{default local},
Wait( 0.1 );
If( ns:nit > 1,
If( Is Scriptable( ns:dla ),
sd = ns:dla << Summary( Group( Column( ns:dla, ns:tool ) ), "Private" );
Current Data Table( sd );
sm = 0;
For( k = 1, k <= ns:nit, k++,
sm += Selected( Row State( k ) )
);
For( i = 1, i <= ns:nit, i++,
c = Color To HLS( Color Of( Row State( i ) ) );
s = Selected( Row State( i ) );
If( Is Scriptable( c ) & N Items( c ) == 3,
If( sm != 0,
If( s == 1,
ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 - 0.5 * c[2], c[3] ) ) << Line Width( 4 )),
ns:biv << (Curve[i] << Line Color( HLS Color( c[1], 0.5 + 0.5 * c[2], c[3] ) ) << Line Width( 1 ))
),
ns:biv << (Curve[i] << Line Color( HLS Color( c[1], c[2], c[3] ) ) << Line Width( 3 ))
)
);
);
Close( sd, nosave );
)
);
);
New Window( "Explore the SegFault",
Outline Box( "Bivariate and Oneway",
H List Box(
biv = Bivariate(
Y( :Name( "Salary" ) ),
X( :Name( "Birth Year" ) ),
SendToReport( Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 400, 300 ), Marker Size( 3 )} ) )
);
biv << Group By( "Gender" );
biv << Fit Spline( 1, standardized );
bivr = biv << Report();
bivr[Outline Box( 1 )] << Set Title( "Salary vs. Birth Year" );
bivr[Picture Box( 2 )] << Delete;
N = N Items( Associative Array( Column( dt, "Gender" ) ) << Get Keys );
For( i = 1, i <= N, i++,
biv << (Curve[i] << Report( 0 ))
);
biv;,
ow = Oneway(
Y( :Name( "Salary" ) ),
X( :Name( "Gender" ) ),
All Graphs( 0 ),
Means and Std Dev( 1 ),
Plot Quantile by Actual( 1 ),
Line of Fit( 0 ),
Box Plots( 1 ),
Mean Error Bars( 1 ),
Std Dev Lines( 1 ),
Connect Means( 1 ),
X Axis Proportional( 0 ),
Points Jittered( 1 ),
Points Spread( 1 ),
SendToReport(
Dispatch(
{"Normal Quantile Plot"},
"Oneway QuantilePlot",
FrameBox,
{Frame Size( 350, 300 ), Marker Size( 3 ), Row Legend(
Column( dt, "Gender" ),
Marker( 1 ),
Marker Theme( "Paired" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
);
owr = ow << Report();
owr[Table Box( 1 )] << Set Selectable Rows();
owr[Outline Box( 1 )] << Set Title( "Proability Plot" );
legend = owr[String Col Box( 2 )];
legend << Sib Append( Number Col Box( "Mean", owr[Number Col Box( 2 )] << Get ) );
legend << Sib Append( Number Col Box( "Number", owr[Number Col Box( 1 )] << Get ) );
owr[Lineup Box( 1 )] << delete;
owr[Picture Box( 3 )] << delete;
owr[Outline Box( 2 )] << delete;
owr[Outline Box( 2 )] << Set Title( "" );
ns = New Namespace();
ns:nit = N;
ns:dla = dt;
ns:tool = "Gender";
ns:biv = biv;
owr[Number Col Box( 2 )] << Set Row Change Function( Function( {this}, change_lines( this, ns ) ) );
ow;
)
)
);
Is there anything I can do to not have this error occur? I included the initial Wait function -- it seems to be an issue with the legend selection changing the unselected markers (I have that unselected markers are faded) and perhaps my function is also trying to change the display during an alternate update. Increasing the wait time seems to make the error less frequent, but does not fully alleviate the situation.
Thanks!