cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar

Get label function not working anymore with Get Legend Server in JMP 18.1.1

Hello,

 

The command below works in JMP 17, and allows me to retrieve the label of a legend. But since JMP 18 it no longer works, and I get an error message instead.

 

Does anyone know how to fix this?

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Variables(
		X( :height ),
		Y( :weight ),
		Overlay( :sex ),
		Color( :age )
	),
	Elements(
		Points( X, Y, Legend( 1 ) ),
		Smoother( X, Y, Legend( 2 ) )
	)
);
lgnd = gb << Get Legend Server;
item = (lgnd << Get Legend Items)[1];

show(item[1] << get label());
item[1]  << Set Properties( {Transparency( 1 )} );

SophieCuvillier_0-1737381610819.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

I will take a look this evening my time (currently 13:00).

 

Could something like this help for now Column Quick Swapper - easily change multiple Y and X-axis columns in Graph Builder I did notice that it doesn't work if you have transform column, so you would have to move your X axis to table column but after that it seems to work

jthi_0-1737630032827.png

jthi_1-1737630040209.png

(The add-in doesn't manipulate Legend it manipulates Y-axis variables) there is also wish list item in hopes for JMP to support that type of functionalities natively New filter "Column Filter" a combination of Local Data Filter and Column Switcher 

-Jarmo

View solution in original post

jthi
Super User

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

Seems to be a mess, but maybe this gives some ideas

Names Default To Here(1);

cols = {"wx0b5t", "wx0bgw", "wx0c0y", "wx0c0z", "wx0cfl", "wx0cfn", "WX0AZN", "WX0c03", "WX0C0X", "WX0CFM", "WX0cow"};

dt = Open("$DOWNLOADS/Guardband table_for_reprex2.jmp");

gb = dt << Graph Builder(
	Transform Column("Row", Formula(Row())),
	Size(1149, 561),
	Show Control Panel(0),
	Variables(
		X(:Row),
		Y(:wx0b5t),
		Y(:"OOC - wx0b5t"n, Position(1)),
		Y(:wx0bgw, Position(1)),
		Y(:"OOC - wx0bgw"n, Position(1)),
		Y(:wx0c0y, Position(1)),
		Y(:"OOC - wx0c0y"n, Position(1)),
		Y(:wx0c0z, Position(1)),
		Y(:"OOC - wx0c0z"n, Position(1)),
		Y(:wx0cfl, Position(1)),
		Y(:"OOC - wx0cfl"n, Position(1)),
		Y(:wx0cfn, Position(1)),
		Y(:"OOC - wx0cfn"n, Position(1)),
		Y(:WX0AZN, Position(1)),
		Y(:"OOC - WX0AZN"n, Position(1)),
		Y(:WX0c03, Position(1)),
		Y(:"OOC - WX0c03"n, Position(1)),
		Y(:WX0C0X, Position(1)),
		Y(:"OOC - WX0C0X"n, Position(1)),
		Y(:WX0CFM, Position(1)),
		Y(:"OOC - WX0CFM"n, Position(1)),
		Y(:WX0cow, Position(1)),
		Y(:"OOC - WX0cow"n, Position(1))
	),
	Elements(
		Line(
			X,
			Y(1),
			Y(2),
			Y(3),
			Y(4),
			Y(5),
			Y(6),
			Y(7),
			Y(8),
			Y(9),
			Y(10),
			Y(11),
			Y(12),
			Y(13),
			Y(14),
			Y(15),
			Y(16),
			Y(17),
			Y(18),
			Y(19),
			Y(20),
			Y(21),
			Y(22),
			Legend(16),
			Error Interval("None"),
			Missing Values("No Connection")
		)
	),
	SendToReport(
		Dispatch({}, "Row", ScaleBox, {Min(0), Max(1136), Inc(10), Minor Ticks(4), Label Row(Label Orientation("Angled"))}),
		Dispatch({}, "400", ScaleBox,
			{Legend Model(
				16,
				Properties(0, {Line Width(1)}, Item ID("wx0b5t", 1)),
				Properties(1, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0b5t", 1)),
				Properties(2, {Line Width(1)}, Item ID("wx0bgw", 1)),
				Properties(3, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0bgw", 1)),
				Properties(4, {Line Width(1)}, Item ID("wx0c0y", 1)),
				Properties(5, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0c0y", 1)),
				Properties(6, {Line Width(1)}, Item ID("wx0c0z", 1)),
				Properties(7, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0c0z", 1)),
				Properties(8, {Line Width(1)}, Item ID("wx0cfl", 1)),
				Properties(9, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0cfl", 1)),
				Properties(10, {Line Width(1)}, Item ID("wx0cfn", 1)),
				Properties(11, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0cfn", 1)),
				Properties(12, {Line Width(1)}, Item ID("WX0AZN", 1)),
				Properties(13, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0AZN", 1)),
				Properties(14, {Line Width(1)}, Item ID("WX0c03", 1)),
				Properties(15, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0c03", 1)),
				Properties(16, {Line Width(1)}, Item ID("WX0C0X", 1)),
				Properties(17, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0C0X", 1)),
				Properties(18, {Line Width(1)}, Item ID("WX0CFM", 1)),
				Properties(19, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0CFM", 1)),
				Properties(20, {Line Width(1)}, Item ID("WX0cow", 1)),
				Properties(21, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0cow", 1))
			)}
		),
		Dispatch({}, "graph title", TextEditBox, {Set Text("Reproducible example")}),
		Dispatch({}, "X title", TextEditBox, {Set Text("Time [min]")}),
		Dispatch({}, "Y title", TextEditBox, {Set Text("Y")}),
		Dispatch({}, "Graph Builder", FrameBox, {Background Color(-14605016), Marker Size(0), Marker Drawing Mode("Normal")}),
		Dispatch({}, "400", LegendBox,
			{Legend Position({16, [0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1]})}
		)
	)
);

s = gb << get script;
l_model = Try(Arg(Extract Expr(s, Legend(Wild()))), .);


hide_column_line = function({gb, cols_to_show}, {Default Local},
	l_server = gb << Get Legend Server;
	server_items = (lgnd << Get Legend Items)[1];
	
	l_display = gb << Get Legend Display;
	display_items = l_display << get items;
	
	For(i = 1, i <= N Items(server_items), i++,
		item = Eval(EvalExpr(l_server << Get Legend Item(Expr(l_model), Expr(i))));
		If(!Contains(cols_to_show, item << Get Label),
			item << Set Properties({Transparency(0)});
			display_items[i] << Set Visible(0);
		,
			item << Set Properties({Transparency(1)});
			display_items[i] << Set Visible(1);
		);
	);
);

wait(1);
hide_column_line(gb, cols[1]);
wait(1);
hide_column_line(gb, cols[3::6]);
wait(1);
hide_column_line(gb, cols);
-Jarmo

View solution in original post

8 REPLIES 8
jthi
Super User

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

One option is to use a bit different syntax

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Variables(X(:height), Y(:weight), Overlay(:sex), Color(:age)),
	Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
);
lgnd = gb << Get Legend Server;
item = lgnd << Get Legend Item(1, 1);
Show(item << get label());
item << Set Properties({Transparency(0.2)});

Legend Model / Legend Server / Legend Display is one of the (most) annoying things in JMP to work through JSL with and it might break in a bit weird ways between version changes...

-Jarmo
jthi
Super User

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

Scripting Index does also offer two options (search for Get Label). Get Legend Item doesn't have documentation so it might be safer to use Legend Display + << Get Item

 

Using Legend Display

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Variables(X(:height), Y(:weight), Overlay(:sex), Color(:age)),
	Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
);
lgnd = gb << Get Legend Display;
item = lgnd << Get Item(2, 1);
Print(item << Get Label);

jthi_0-1737382536188.png

Using Legend Server

jthi_1-1737382545378.png

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Variables(X(:height), Y(:weight), Overlay(:sex), Color(:age)),
	Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
);
server = gb << Get Legend Server;
item = server << Get Legend Item(2, 1);
Print(item << Get Label);
-Jarmo

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

Hello,

 

Thank your for your answer, your change works. But I'm having trouble understanding what the function arguments (A,B) are and where to find them in Get Legend Item(A,B). Basically, I want to loop through my list of items and make transparent those that have a specific label. Naively, I was using Get Legend Item(i, 1), thinking that it was the i-th item, but it's obviously the ID model and I'm getting a bit confused.

 

SophieCuvillier_0-1737385372582.png

 

jthi
Super User

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

I think in that case you can use << Get Items (this might have had a bug with some earlier JMP18 version than 18.1.1 if you were to use For Each loop but seems to work in 18.1.1)

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
	Variables(X(:height), Y(:weight), Overlay(:sex), Color(:age)),
	Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
);
lgnd = gb << Get Legend Display;
items = lgnd << Get Items;
For Each({item}, items,
	show(item << get label);
);
-Jarmo

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

Hello,

 

Thank you again for your answer ! That doesn't solve my problem, but I haven't explained the context sufficiently. More details below. I have a script that allows me to see how my batches evolve over time. This script also generates a listbox with the list of my batches. If I click on a value, it will only display the evolution of this batch.

SophieCuvillier_0-1737628635073.png

After clicking on one or several batches - expected results:
 
SophieCuvillier_1-1737628660827.png

 


 

And that's where we come back to the part that crashes and that you helped me with. But the proposed fix, for some reason that I don't know, makes the legend disappear right away, but not the lines in the graph.

 

SophieCuvillier_3-1737628869938.png

 

 

jthi
Super User

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

I will take a look this evening my time (currently 13:00).

 

Could something like this help for now Column Quick Swapper - easily change multiple Y and X-axis columns in Graph Builder I did notice that it doesn't work if you have transform column, so you would have to move your X axis to table column but after that it seems to work

jthi_0-1737630032827.png

jthi_1-1737630040209.png

(The add-in doesn't manipulate Legend it manipulates Y-axis variables) there is also wish list item in hopes for JMP to support that type of functionalities natively New filter "Column Filter" a combination of Local Data Filter and Column Switcher 

-Jarmo
jthi
Super User

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

Seems to be a mess, but maybe this gives some ideas

Names Default To Here(1);

cols = {"wx0b5t", "wx0bgw", "wx0c0y", "wx0c0z", "wx0cfl", "wx0cfn", "WX0AZN", "WX0c03", "WX0C0X", "WX0CFM", "WX0cow"};

dt = Open("$DOWNLOADS/Guardband table_for_reprex2.jmp");

gb = dt << Graph Builder(
	Transform Column("Row", Formula(Row())),
	Size(1149, 561),
	Show Control Panel(0),
	Variables(
		X(:Row),
		Y(:wx0b5t),
		Y(:"OOC - wx0b5t"n, Position(1)),
		Y(:wx0bgw, Position(1)),
		Y(:"OOC - wx0bgw"n, Position(1)),
		Y(:wx0c0y, Position(1)),
		Y(:"OOC - wx0c0y"n, Position(1)),
		Y(:wx0c0z, Position(1)),
		Y(:"OOC - wx0c0z"n, Position(1)),
		Y(:wx0cfl, Position(1)),
		Y(:"OOC - wx0cfl"n, Position(1)),
		Y(:wx0cfn, Position(1)),
		Y(:"OOC - wx0cfn"n, Position(1)),
		Y(:WX0AZN, Position(1)),
		Y(:"OOC - WX0AZN"n, Position(1)),
		Y(:WX0c03, Position(1)),
		Y(:"OOC - WX0c03"n, Position(1)),
		Y(:WX0C0X, Position(1)),
		Y(:"OOC - WX0C0X"n, Position(1)),
		Y(:WX0CFM, Position(1)),
		Y(:"OOC - WX0CFM"n, Position(1)),
		Y(:WX0cow, Position(1)),
		Y(:"OOC - WX0cow"n, Position(1))
	),
	Elements(
		Line(
			X,
			Y(1),
			Y(2),
			Y(3),
			Y(4),
			Y(5),
			Y(6),
			Y(7),
			Y(8),
			Y(9),
			Y(10),
			Y(11),
			Y(12),
			Y(13),
			Y(14),
			Y(15),
			Y(16),
			Y(17),
			Y(18),
			Y(19),
			Y(20),
			Y(21),
			Y(22),
			Legend(16),
			Error Interval("None"),
			Missing Values("No Connection")
		)
	),
	SendToReport(
		Dispatch({}, "Row", ScaleBox, {Min(0), Max(1136), Inc(10), Minor Ticks(4), Label Row(Label Orientation("Angled"))}),
		Dispatch({}, "400", ScaleBox,
			{Legend Model(
				16,
				Properties(0, {Line Width(1)}, Item ID("wx0b5t", 1)),
				Properties(1, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0b5t", 1)),
				Properties(2, {Line Width(1)}, Item ID("wx0bgw", 1)),
				Properties(3, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0bgw", 1)),
				Properties(4, {Line Width(1)}, Item ID("wx0c0y", 1)),
				Properties(5, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0c0y", 1)),
				Properties(6, {Line Width(1)}, Item ID("wx0c0z", 1)),
				Properties(7, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0c0z", 1)),
				Properties(8, {Line Width(1)}, Item ID("wx0cfl", 1)),
				Properties(9, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0cfl", 1)),
				Properties(10, {Line Width(1)}, Item ID("wx0cfn", 1)),
				Properties(11, {Line Color(3), Line Width(1)}, Item ID("OOC - wx0cfn", 1)),
				Properties(12, {Line Width(1)}, Item ID("WX0AZN", 1)),
				Properties(13, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0AZN", 1)),
				Properties(14, {Line Width(1)}, Item ID("WX0c03", 1)),
				Properties(15, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0c03", 1)),
				Properties(16, {Line Width(1)}, Item ID("WX0C0X", 1)),
				Properties(17, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0C0X", 1)),
				Properties(18, {Line Width(1)}, Item ID("WX0CFM", 1)),
				Properties(19, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0CFM", 1)),
				Properties(20, {Line Width(1)}, Item ID("WX0cow", 1)),
				Properties(21, {Line Color(3), Line Width(1)}, Item ID("OOC - WX0cow", 1))
			)}
		),
		Dispatch({}, "graph title", TextEditBox, {Set Text("Reproducible example")}),
		Dispatch({}, "X title", TextEditBox, {Set Text("Time [min]")}),
		Dispatch({}, "Y title", TextEditBox, {Set Text("Y")}),
		Dispatch({}, "Graph Builder", FrameBox, {Background Color(-14605016), Marker Size(0), Marker Drawing Mode("Normal")}),
		Dispatch({}, "400", LegendBox,
			{Legend Position({16, [0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1]})}
		)
	)
);

s = gb << get script;
l_model = Try(Arg(Extract Expr(s, Legend(Wild()))), .);


hide_column_line = function({gb, cols_to_show}, {Default Local},
	l_server = gb << Get Legend Server;
	server_items = (lgnd << Get Legend Items)[1];
	
	l_display = gb << Get Legend Display;
	display_items = l_display << get items;
	
	For(i = 1, i <= N Items(server_items), i++,
		item = Eval(EvalExpr(l_server << Get Legend Item(Expr(l_model), Expr(i))));
		If(!Contains(cols_to_show, item << Get Label),
			item << Set Properties({Transparency(0)});
			display_items[i] << Set Visible(0);
		,
			item << Set Properties({Transparency(1)});
			display_items[i] << Set Visible(1);
		);
	);
);

wait(1);
hide_column_line(gb, cols[1]);
wait(1);
hide_column_line(gb, cols[3::6]);
wait(1);
hide_column_line(gb, cols);
-Jarmo

Re: Get label function not working anymore with Get Legend Server in JMP 18.1.1

Thank you very much !!! That works now ! 

Recommended Articles