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

Using functions within Graph Builder Dispatch

I am building a tool for some custom graphs. I want the tool to be easily modified by users that I share it with. To reduce the barrier for entry I would like to use sub-functions which I call within a master function. Each sub function would represent a smaller part of the overall main function.


My question: Is it possoble to replace the arguments of 'Dispatch' within the graph builder as a function? Or is there another standard approach to creating smaller sub functions that I am not aware of.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Using functions within Graph Builder Dispatch

Here is some code that accomplishes what you want, but it isn't very pretty.  What you want is to be able to do code generation with substitution, and that isn't handled very well in JMP.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
myfunc = Function( {},
	return =
	"\[Dispatch(
				{},
				"2",
				ScaleBox,
				{Min( 92.9916666666667 ), Max( 127 ), Inc( 5 ), Minor Ticks( 1 ),
				Add Ref Line( 118.356215277778, "Solid", "Black", "", 1 )}
			)]\"
);


Eval(
	Substitute(
			Expr(
				Bivariate( Y( :NPN1 ), X( :PNP1 ), SendToReport( __dispatch__ ) )
			),
		Expr( __dispatch__ ), Parse( myfunc )
	)
);

JMP can handle replacement of components within the platform structure, such as passing in a minimum value.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );

mymin = 80;

Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	SendToReport(
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Min( Eval( mymin ) ), Max( 127 ), Inc( 5 ), Minor Ticks( 1 ),
			Add Ref Line( 118.356215277778, "Solid", "Black", "", 1 )}
		)
	)
	
);

Or what I believe is the prefered method, which is to generate the default graph, and then set the parameters after the generation, where a call to a function could be used to conditionally set the items desired;

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );

myfunc = function({},
	Report( biv )[Axis Box( 1 )] << Min( 80 );
);

biv = Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	SendToReport(
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Min( 92.9916666666667 ), Max( 127 ), Inc( 5 ), Minor Ticks( 1 ),
			Add Ref Line( 118.356215277778, "Solid", "Black", "", 1 )}
		)
	)
);

myfunc;
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Using functions within Graph Builder Dispatch

If you look at:

     Help==>Scripting Index==>Graph Builder

you will see all of the various components that can be manipulated in Graph Builder, by passing requests to the platform.  All of these can be put into user build functions.

graph builder help.PNG

Jim
kevinwtbolger
Level II

Re: Using functions within Graph Builder Dispatch

Hi Jim,

 

Thanks for the reply. However I'll try make my problem a little clearer.

 

Lets say within Graph Builder in my JSL script, I have some code block such as:

 

Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(... etc

In this perhaps for example I am customising the color of lines.

 

Is it possible for me to create a function in another JSL Script such as:

myDispatch=Function(
	{},
	
	Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(.... etc

and then within the JSL script, in place of the dispatch function, I would have myDispatch().

I have tried this, and while it doesnt log any errors, it does not apply my function (ie the graph just uses the default line colors etc and ignores my function). I cant get it to work without explicitly typing the arguments within the Graph Builder itself.

 

Many Thanks

txnelson
Super User

Re: Using functions within Graph Builder Dispatch

Here is some code that accomplishes what you want, but it isn't very pretty.  What you want is to be able to do code generation with substitution, and that isn't handled very well in JMP.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );
myfunc = Function( {},
	return =
	"\[Dispatch(
				{},
				"2",
				ScaleBox,
				{Min( 92.9916666666667 ), Max( 127 ), Inc( 5 ), Minor Ticks( 1 ),
				Add Ref Line( 118.356215277778, "Solid", "Black", "", 1 )}
			)]\"
);


Eval(
	Substitute(
			Expr(
				Bivariate( Y( :NPN1 ), X( :PNP1 ), SendToReport( __dispatch__ ) )
			),
		Expr( __dispatch__ ), Parse( myfunc )
	)
);

JMP can handle replacement of components within the platform structure, such as passing in a minimum value.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );

mymin = 80;

Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	SendToReport(
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Min( Eval( mymin ) ), Max( 127 ), Inc( 5 ), Minor Ticks( 1 ),
			Add Ref Line( 118.356215277778, "Solid", "Black", "", 1 )}
		)
	)
	
);

Or what I believe is the prefered method, which is to generate the default graph, and then set the parameters after the generation, where a call to a function could be used to conditionally set the items desired;

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\semiconductor capability.jmp" );

myfunc = function({},
	Report( biv )[Axis Box( 1 )] << Min( 80 );
);

biv = Bivariate(
	Y( :NPN1 ),
	X( :PNP1 ),
	SendToReport(
		Dispatch(
			{},
			"2",
			ScaleBox,
			{Min( 92.9916666666667 ), Max( 127 ), Inc( 5 ), Minor Ticks( 1 ),
			Add Ref Line( 118.356215277778, "Solid", "Black", "", 1 )}
		)
	)
);

myfunc;
Jim
kevinwtbolger
Level II

Re: Using functions within Graph Builder Dispatch

Thanks Jim for the thorough response. I figured I would have to pass it as text and parse it somehow but I certainly didnt anticipate it being so ugly! Oh well, I guess this is the price I pay for having such a niche requirement. This is perfect for me though. As long as I can hide most of the ugly code in the master function Im happy as my goal is for that to be left alone by the end user. I'm very much a taker in the community at the moment but I hope I can repay the help by contributing back as I get some more experience with the scripting in JMP.