cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

issue with get legend items

hogi
Level XII

In JMP18 (18.1.1) this example from scripting index doesn't work:

hogi_2-1735559112278.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;
items = server << Get Legend Items;
For Each( {item, index}, items[1],
	item << Set Label( "Item " || Char( index ) )
);

 

It produces the error message:

hogi_1-1735559069148.png

so, Legend Server <<  get legend items()

doesn't return scriptable objects?

5 REPLIES 5
hogi
Level XII


Re: get legend items: no scriptable objects

workaround:
use get legend item


Don't forget to pre-evaluate i for get legend item

- for set label no pre-evaluation is needed.

 

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;
Nitems = Nitems(( server << Get Legend Items)[1]);
for(i=1, i<= Nitems, i++, 
Eval(Eval Expr(item = server  << Get Legend Item(1, Expr(i))));
	item << Set Label( "Item " || Char( i ) )
);
hogi
Level XII


Re: get legend items: no scriptable objects

Next trap: doesn' work for Bar Graphs ?

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb =Graph Builder(
	Variables( X( :age ), Y( :weight ), Overlay( :sex ) ),
	Elements( Bar( X, Y ) )
);
server = gb << Get Legend Server;

items = server << Get Legend Items;
show(items);

server << get legend item(1,1) // error message

hogi_0-1735561837580.png
edit: I could not reproduce the issue on another computer / after a restart of JMP (?).

mmarchandFSLR
Level IV


Re: get legend items: no scriptable objects

It actually does return scriptable objects.  Looks like this is a bug with For Each().  If you change the code to something that should be equivalent, it works.

 

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;
items = server << Get Legend Items;
For Each( {item, index}, items[1],
	items[1][index] /*isn't this exactly what item is?*/ << Set Label( "Item " || Char( index ) )
);
hogi
Level XII


Re: get legend items: no scriptable objects

Ah, sorry, you are right, the individual items are indeed scriptable.

 

Interesting: a batch message like items << get label produces the same issue.
maybe batch messages use for each in the background ?

Digging deeper, I found an old ticket: TS-00128192

Fortunately, in the mean time the issue got enough prio -- in JMP19 (EA5) it's fixed:

hogi_0-1735595525931.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;
items = server << Get Legend Items;items << get label // same issue as with for each

show(items[1][1])
items[1][1] << get label(); // OK, on the lowest level, there is a scriptable object 

Show(tmp = items[1][1::2]); // then this is a list of ...
tmp[1] << get Label(); // ...no

 

hogi
Level XII


Re: get legend items: no scriptable objects


@mmarchandFSLR wrote:

It actually does return scriptable objects.  

on the other hand ... a bit surprising:

hogi_3-1735596775364.png

 


JMP19:

hogi_4-1735596861811.png