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
jemg
Level III

solved

solved

MGO
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Use IF statement with Graph Builder (Dispatch)

You can generate the dynamic part of the Legend Position and build the required list

Names Default To Here( 1 );
uni_bat = {a, b, c, d};

theList = {9, 10, [-1, -1, -1, -1]};

mat = Shape( Matrix( Index( 1, N Items( uni_bat ) - 1 ) ), N Items( uni_bat ) - 1 ) |/ 
	[-1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1];

insert into(theList, mat, 2);

show(theList);

and then plug it into the Legend Position message as demonstrated in the below simplified example

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Show Control Panel( 0 ),
	Variables(
		X( :height ),
		Y( :weight ),
		Overlay( :sex )
	),
	Elements(
		Points( X, Y, Legend( 3 ) ),
		Smoother( X, Y, Legend( 4 ) )
	)
);
theList = {3, 4, [2, 1]};
mat = [4,3];
insert into(theList,mat,2);
eval(parse("Report( gb )[LegendBox( 1 )] << Legend Position( "||char(theList)||" );"));
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Use IF statement with Graph Builder (Dispatch)

The JSL code you are attempting to modify, can be more easily handled using messages sent to the Legend Box() messages.  Below is the entry from the Scripting Index that gives an example of modifying the Legend Position.  Using this method, your IF() statement structure will work as you assumed it would in your example.

txnelson_0-1637748639364.png

Go to

     Help=>Scripting Index

to access the above display

 

Jim
jemg
Level III

Re: Use IF statement with Graph Builder (Dispatch)

solved

MGO
txnelson
Super User

Re: Use IF statement with Graph Builder (Dispatch)

You can generate the dynamic part of the Legend Position and build the required list

Names Default To Here( 1 );
uni_bat = {a, b, c, d};

theList = {9, 10, [-1, -1, -1, -1]};

mat = Shape( Matrix( Index( 1, N Items( uni_bat ) - 1 ) ), N Items( uni_bat ) - 1 ) |/ 
	[-1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1];

insert into(theList, mat, 2);

show(theList);

and then plug it into the Legend Position message as demonstrated in the below simplified example

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Show Control Panel( 0 ),
	Variables(
		X( :height ),
		Y( :weight ),
		Overlay( :sex )
	),
	Elements(
		Points( X, Y, Legend( 3 ) ),
		Smoother( X, Y, Legend( 4 ) )
	)
);
theList = {3, 4, [2, 1]};
mat = [4,3];
insert into(theList,mat,2);
eval(parse("Report( gb )[LegendBox( 1 )] << Legend Position( "||char(theList)||" );"));
Jim
jemg
Level III

Re: Use IF statement with Graph Builder (Dispatch)

 

Thanks to the example you provided in detail, ALL ISSUES (Q1, Q2) have been resolved.

 

theList = {9, 10, [-1, -1, -1, -1]}; 
mat = Shape( Matrix( Index( 0, N Items( uni_bat ) - 1 ) ),
N Items( uni_bat ) ) |/ [-1, -1, -1, -1, -1, -1, -1, -1];

As above, in the script you gave me, I was able to make the result completely what I wanted by adding 0 in front of N items.

 

Thank you again Jim for always kind answers!!!

Please be careful COVID19!

MGO