cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
matth1
Level IV

Show labels for selected rows only

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!

 

matth1_0-1717576334539.png 

matth1_1-1717576383440.png

But if I click LOUISE again, it becomes correctly labelled:

matth1_2-1717576419863.png

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.

 

4 REPLIES 4
jthi
Super User

Re: Show labels for selected rows only

I think you might have to use something to cause a small delay. One option is row state handler (these can be very unreliable) + run formulas

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();

f = Function({a},
	dt << run formulas;
);
rs = dtb1 << Make RowState Handler(f);
-Jarmo
matth1
Level IV

Re: Show labels for selected rows only

Thanks for the suggestion! Unfortunately it didn't work for me as is, but the following does:

 

 

f = Function({a},
	rr = dt << get selected rows;
	dt << clear select;
	wait(0);
	dt << select rows( rr );
	rs = dt << Make Row State Handler(f);
);
rs = dt << Make Row State Handler(f);

However, it feels like a horrible workaround. The Make Row State Handler statement inside the function seems to be necessary because after the first call of f() the handler gets forgotten (not sure I understand what's happening here!). 

 

 

jthi
Super User

Re: Show labels for selected rows only

It doesn't work with the code I provided or when using similar idea on your data (for me it works using JMP17.2/JMP18.0 on Windows 10)?

-Jarmo
matth1
Level IV

Re: Show labels for selected rows only


@jthi wrote:

It doesn't work with the code I provided or when using similar idea on your data (for me it works using JMP17.2/JMP18.0 on Windows 10)?


Your simple function using << run formulas doesn't work for me in JMP 17.2/18.0 on Mac OS 13.6.7.