cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Juber
Level II

If statement inside graph builder for SendToReport functionality

Hi,

I want to be able to change the graph's Y-axis only when the Y-axis is a certain column(say errors). But looks like the graphbuilder doesn't recognize the if inside it. However, this works fine when i don't use the if statement. But i want to be able to use this same graph function for all kinds of graphs. 

graph_func = function({stackdt,title},{Default Local},
				gb = Graph Builder(
					Size( 1342, 905 ),
					Variables(
						X( :names ),
						Y( as column(title) ),
						Group X( :Type ),
						Overlay( :GROUPs )
					),
					Elements( Box Plot( X, Y, Legend( 11 ) ) ),
					Local Data Filter(
					Add Filter(
						columns( :Type), 
						Display( :Type, Size( 160, 30 ), List Display )
					)	),
				if(contains(title,"error"),
					SendToReport(
						Dispatch(
							{},
							title,
							ScaleBox,
							{Scale( "Log" ), Format( "Scientific", 10 ), Min( 0.00001 ), Max( 0.03 ),
							Inc( 1 ), Minor Ticks( 1 )}
						)
					) , )  );
				return(gb);
);
5 REPLIES 5

Re: If statement inside graph builder for SendToReport functionality

As I have mentioned in other discussions, Send To Report() is intended for JMP to be able to save a script for you and capture any customization that you might have done. There are better ways to customize your window when you are writing a script. For example,

 

gb = dt << Graph Builder( /* usual plot arguments */ );

If( error plot,
	Report( gb )[AxisBox(1)] << Min( 0 ) << Max( 10 ) << Inc( 1 );
);

I would launch Graph Builder with the default customization (not for plotting errors). I would have a way of flagging the exception (plotting errors) and use the If() function to determine if messages should be sent to the object. In the example above, the error plot argument could be a flag (Boolean variable) or it could be an expression that returns true when you a plotting the errors. The messages are sent to the vertical axis in this case to change the scale. You can use this illustration  of build any customization that you like.

txnelson
Super User

Re: If statement inside graph builder for SendToReport functionality

An easier way to do this is by passing messages to the display objects created by Graph Builder.  The messages can be pass after the graph is produced.  All of these messages are documented in the Scripting Index

     Help==>Scripting Index

and then look for the AxisBox object

Here is a modification to your code that should work

graph_func = Function( {stackdt, title},
	{Default Local},
	gb = Graph Builder(
		Size( 1342, 905 ),
		Variables( X( :names ), Y( As Column( title ) ), Group X( :Type ), Overlay( :GROUPs ) ),
		Elements( Box Plot( X, Y, Legend( 11 ) ) ),
		Local Data Filter( Add Filter( columns( :Type ), Display( :Type, Size( 160, 30 ), List Display ) ) )
		
	);
If( Contains( title, "error" ),	
	report(gb)[AxisBox(2)] << min(0.00001) << Max( 0.03 ) << Inc( 1 ) <<Minor Ticks( 1 ) << Format( "Scientific", 10 );
);	
	
	Return( gb );
);
Jim
Juber
Level II

Re: If statement inside graph builder for SendToReport functionality

Thanks for replying. I tried the 2nd solution as that looked straightforward with what I'm doing. It works but the Y-axis has only 2 points now i.e. min and max. How do i make it display the scale on Yaxis?
txnelson
Super User

Re: If statement inside graph builder for SendToReport functionality

Could you please supply your JSL and an image of the display output.

Jim
Juber
Level II

Re: If statement inside graph builder for SendToReport functionality

Juber_0-1580494669919.png Can't really supply the JSL or the entire graph because of company's privacy policy, but here's what the X-axis looks like. There are 3 groups on the Group Y axis and errors on Y-axis. I want to be able to see all the intermediate points on y-axis and not just min and max like how it is.

Also, when i split a different group according to page, this only applies to the 1st graph and not the subsequent.