cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
miguello
Level VI

How to script a graph with optional variables?

Let's say I need to script a graph. And I have a variable that is optional. I might have it, might not have it. Let's say in the example below I might have "Y_Parameter_Std" in the table, might not have it.

 

How do I script this optional variable? 

 

	gb = Graph Builder(
		Size( 350, 200 ),
		Show Control Panel( 0 ),
		Variables( X( Column( X_Parameter ) ), Y( Column( Y_Parameter ) ), Overlay( :Wafer ID ), Interval( Column(Y_Parameter_Std) ) ),
		Elements(
			Points( X, Y, Legend( 14 ), Interval Style( "Band" ) ),
			Smoother( X, Y, Legend( 15 ), Lambda( 0.1 ) ), 
		
		)
	);

The way I'm going to try it is this:

Have script for the GB in an expression variable with a placeholder for Interval. If there is a column for interval - replace placeholder with the corresponding expression. If not - replace it with "".

Any other more elegant way?

 

Thanks, 

M

4 REPLIES 4
jthi
Super User

Re: How to script a graph with optional variables?

In simple cases it is easiest to just use if-statement and two separate graph builder messages

-Jarmo
miguello
Level VI

Re: How to script a graph with optional variables?

Well, I have to feed column names into the GB expression anyways, they are not hardcoded, so might as well work on this too.

Just wondering which of the ways of dealing with expressions is the best.

 

I remember there was a post on them, maybe even by you, Jarmo, on common ways?

jthi
Super User

Re: How to script a graph with optional variables?

I have demonstrated them few times in community (if you manage to find the posts, not easy with community search), there is one related topic in scripters club and there are more posts also in community. 

 

Scripters Club Recording: JSL in Graph Builder 

Reply All: How to script dynamic content for Graph Builder 

How do I use jsl add X variable to graphbuilder 

Graph builder element loop function 

-Jarmo

Re: How to script a graph with optional variables?

Hi @miguello ,

 

Might be worth looking a this post in the JSL cookbook it focuses on how to run platforms when the number or names of columns can change.

 

Thanks,

Ben

“All models are wrong, but some are useful”

Recommended Articles