BookmarkSubscribe
Choose Language Hide Translation Bar
KC
KC
Community Member

How to set legendbox position by passing variable?

Hi,

I want to set  LegendBox position by a list  as following jsl, but it is not work. how do I pass the "mylist " into position?

the list "mylist" will be  a dynamic result from other funciton , so I need to pass the variable  while setup graph builder  or update the graph builder after announcement.

I need the graph legendbox like the picture.  

 

 

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( 0 ) ),
		Smoother( X, Y, Legend( 1 ) )
	)
);

mylist={-1, -1, 1, 0};

Report( gb )[LegendBox( 1 )] << Position(mylist );

 position.JPG

 

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to set legendbox position by passing variable?

The Position Message apparently does not support evaluation prior to its execution, therefore by using the Substitute() function you can force the evaluation.

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( 0 ) ),
		Smoother( X, Y, Legend( 1 ) )
	)
);

mylist = {-1, -1, 1, 0};
Eval(
	Substitute(
			Expr(
				Report( gb )[LegendBox( 1 )] << Position( __myList__ )
			),
		Expr( __myList__ ), myList
	)
);
Jim
1 REPLY 1
txnelson
Super User

Re: How to set legendbox position by passing variable?

The Position Message apparently does not support evaluation prior to its execution, therefore by using the Substitute() function you can force the evaluation.

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( 0 ) ),
		Smoother( X, Y, Legend( 1 ) )
	)
);

mylist = {-1, -1, 1, 0};
Eval(
	Substitute(
			Expr(
				Report( gb )[LegendBox( 1 )] << Position( __myList__ )
			),
		Expr( __myList__ ), myList
	)
);
Jim