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
Clanlope
Level II

[JMP12 JSL for Graph Builder] Failed to add new element into each position

Hi, currently I hope to add new element into each position for my chart, chart with one X-axis and several Y-axes;

 

so I use the code below:

 

For(jj = 1, jj <= 20, jj++,

gb << Elements( Position( 1, jj ), Points( X, Y , Legend( 1 )), Smoother( X, Y , Legend( 2 ) ) );

);

 

However, the chart created with this code still with 1 elements only, I right click the chart there are 2 elements shown though.

When I perform redo analyse, the new chart created as expected but I don't know why.

 

Since I am now using JMP12, is it caused by the dated version?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: [JMP12 JSL for Graph Builder] Failed to add new element into each position

I tested the JSL under JMP 12.2 and in order to get the Legend to appear correctly I needed to make a minor change.

txnelson_0-1728300074995.png

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt << New Column( "Ratio", formula( :Height / :Weight ) );
gb = Graph Builder( Variables( X( :age ), Y( :height ), Y( :weight ), Y( :ratio ) ) );
For( jj = 1, jj <= 20, jj++,
	Eval(
		Eval Expr(
			gb << Elements(
				Position( 1, Expr( jj ) ),
				Points( X, Y, Legend( Expr( jj * 2 ) ) ),
				Smoother( X, Y, Legend( Expr( jj * 2 + 1 ) ) )
			)
		)
	)
);
Jim

View solution in original post

4 REPLIES 4
jthi
Super User

Re: [JMP12 JSL for Graph Builder] Failed to add new element into each position

I don't have access to JMP12 to test this, but it might be enough if you evaluate jj

Eval(
	EvalExpr(
		gb << Elements(Position(1, Expr(jj)), Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
	)
);
-Jarmo
txnelson
Super User

Re: [JMP12 JSL for Graph Builder] Failed to add new element into each position

I tested the JSL under JMP 12.2 and in order to get the Legend to appear correctly I needed to make a minor change.

txnelson_0-1728300074995.png

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt << New Column( "Ratio", formula( :Height / :Weight ) );
gb = Graph Builder( Variables( X( :age ), Y( :height ), Y( :weight ), Y( :ratio ) ) );
For( jj = 1, jj <= 20, jj++,
	Eval(
		Eval Expr(
			gb << Elements(
				Position( 1, Expr( jj ) ),
				Points( X, Y, Legend( Expr( jj * 2 ) ) ),
				Smoother( X, Y, Legend( Expr( jj * 2 + 1 ) ) )
			)
		)
	)
);
Jim
hogi
Level XII

Re: [JMP12 JSL for Graph Builder] Failed to add new element into each position

and for later versions of JMP?

Clanlope
Level II

Re: [JMP12 JSL for Graph Builder] Failed to add new element into each position

Thanks for your help! After several tries on your solution it worked but not for every time. So I modified my code and found that it may be induced by the code used for changing the marker size/mode.

 

 

TotalFrame = gb << xpath("//FrameBox");
For(ii = 1, ii <= N Items(TotalFrame), ii++,
	gb << SendToReport(
		Dispatch( {}, "Graph Builder", FrameBox( ii ), {Marker Size( 2 ), Marker Drawing Mode( "Outlined" )} ),
	);
);

For( jj = 1 ...

 

After swithing the position, the chart was drawn currently:

For( jj = 1 ...

TotalFrame...

I don't know the reason though the problem has been solved...

Thanks again!