Hello. I am trying to make an interactive graph to display data from a summary table. The goal is to create a line graph with points that can be clicked on to subset data from that particular point. For instance, in the script below, I have a graph of a summary table by age of the Big Class sample table. The user should be able to click on a point on the graph and have it automatically pull up a subset table containing all the data from that point.
The issue I am running in to is that a single click won't work because no data has been selected. The user must double click on a point to select the data, then click again to run the subset expression. Is there a way to do this without having to triple click? Thank you.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dtSummary = dt << Summary(
Group( :age ),
Freq( "None" ),
Weight( "None" ),
output table name( "dtSummary" )
);
gbExpr = Expr(
gb = Graph Builder(
Size( 528, 448 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :N Rows ) ),
Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 4 ) ) ),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {3, [-1], 4, [-1]} ), Position( {-1, -1} )}
)
)
);
);
ExprA = Expr(
dtSubset = dt << Subset( Output Table( "Subset" ), Selected Rows( 1 ), Selected Columns( 0 ));
dtSummary << Clear Selected Rows;
);
GraphWindow = New Window( "Graph" );
GraphWindow << Append(
MouseBox(
gbExpr,
<<SetClickEnable( 1 ),
<<SetClick( Function( {this, clickpt, event}, If(N Rows(dt << Get Selected Rows) < 1,, If( event == "Pressed", Eval( Expr( ExprA ))))))
)
);