In Graph Builder, I want to show a data label (not a hover label) for selected rows only. As a demo, I tried the following code:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Try(
Show( dt:Selected Name ),
dt << New Column( "Selected Name",
Character,
Set Formula( If( Selected( Row State( Row() ) ) == 1, :name ) )
)
);
dt:Name << Label( 0 );
dt << Clear Row States << Select All Rows << Label << Clear Select;
dt:Selected Name << Label( 1 );
// The following doesn't work as expected
gb1 = dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch( {}, "Graph Builder", FrameBox,
{Marker Size( 5 ), Marker Drawing Mode( "Normal" )}
)
)
);
nw1 = New Window( "DTB", dtb1 = Data Table Box( dt ) );
dtb1 << set selectable rows();
When I select a row in the data table, or from the table box, or by selecting the data point in the Graph Builder, it should show the label in :Selected Name. However, it always seems to be one selected point behind! For example, I select KATIE and the data point is highlighted but there's no label. Then if I select LOUISE, the data point for that row is highlighted, but the data point for KATIE is now labelled!
But if I click LOUISE again, it becomes correctly labelled:
Finally, if I deselect all rows then the last label remains visible.
Interestingly, if I use the following code to put the table box and graph builder in the same window, and select rows from the table box or the Graph Builder plot, it works as expected, with the label only showing for the selected rows:
dt << clear select;
nw2 = New Window( "Demo",
H List Box(
dtb2 = Data Table Box( dt ),
gb2 = dt << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 3 ) ) ),
SendToReport(
Dispatch( {}, "Graph Builder", FrameBox,
{Marker Size( 5 ), Marker Drawing Mode( "Normal" )}
)
)
)
)
);
dtb2 << set selectable rows();
Is there a better way for doing what I'm attempting?
I see this behaviour on JMP 17.2 and JMP 18.