Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
Lindeman1arr
Level II

dynamically change Dispatch() options sent to GraphBuilder

I am needing to change some of the options sent to the Graph Builder depending on the options in the script.  I can't figure out how to get it to work.

 

This script works to make the graph Scale("Log"), Format("Engineering", 12):

 

Graph Builder(
		Variables(
			X( :Split ),
			X( :Wafer, Position( 1 ) ),
			Y( As Column( analysisTests[i] ) ),
			Color( :Split )
		),
		Elements(
			Points( X( 1 ), X( 2 ), Y, Legend( 21 ) ),
			Box Plot( X( 1 ), X( 2 ), Y, Legend( 22 ) )
		),
		SendToReport(
			Dispatch(
				{},
				analysisTests[i],
				ScaleBox,
				{Scale("Log"), Format("Engineering", 12)}
			),
			Dispatch(
				{},
				"graph title",
				TextEditBox,
				{Set Text( title )}
			)
		)
	)

 

But when I try and send that information like this it doesn't work, even though it looks the same to me:

 

 

ScaleboxVariables = {};
if(log != 0, ScaleboxVariables = Insert(ScaleboxVariables, Expr(Scale("Log")) ); ScaleboxVariables = Insert(ScaleboxVariables, Expr(Format( "Engineering", 12 )) ); ); Dispatch( {}, analysisTests[i], ScaleBox, ScaleboxVariables ),

 

 

Any help with this would be appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: dynamically change Dispatch() options sent to GraphBuilder

As I have said in answer to many other discussions here, the Send to Report argument was developed so that JMP can save customizations when you save a script. It was not developed for us. There are better ways. Send the Format message directly to the axis box. Like this:

 

Names Default to Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb = dt << Graph Builder(
	Size( 534, 454 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables( X( :height ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);

gb rep = gb << Report;

gb rep[AxisBox(2)] << Format( Engineering, 12 );
Learn it once, use it forever!

View solution in original post

4 REPLIES 4
Highlighted

Re: dynamically change Dispatch() options sent to GraphBuilder

As I have said in answer to many other discussions here, the Send to Report argument was developed so that JMP can save customizations when you save a script. It was not developed for us. There are better ways. Send the Format message directly to the axis box. Like this:

 

Names Default to Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

gb = dt << Graph Builder(
	Size( 534, 454 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables( X( :height ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);

gb rep = gb << Report;

gb rep[AxisBox(2)] << Format( Engineering, 12 );
Learn it once, use it forever!

View solution in original post

Highlighted
txnelson
Super User

Re: dynamically change Dispatch() options sent to GraphBuilder

To add to @markbailey all of the messages and functions that can be passed to the various display objects in the output from JMP platforms are described with examples in the Scripting Index.  .  The output from the various JMP Platforms are displayed in structures filled with objects, called Display Trees. Therefore, I also suggest that you read the section in the Scripting Guide on Display Trees.  It will open a whole new world of the marvelous things one is able to do with the output from JMP Platforms. 

Jim
Highlighted
Craige_Hales
Staff (Retired)

Re: dynamically change Dispatch() options sent to GraphBuilder

Two terms

  • platform object: the logic behind graph builder. It is not visible.
  • report surface display box tree: the output from graph builder. A visible graph, sliders, buttons.

Mark is correct; the dispatch syntax was created for machines, not humans. The Dispatch message contains information the platform object uses to find a display box in the report.  If you need to use it, the SendToReport dispatches must be sent like this:

 

dt = Open( "$sample_data/big class.jmp" );
gb = dt << Graph Builder(
	Size( 512, 442 ),
	Show Control Panel( 0 ),
	Show Legend( 0 ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ) ), 
//	SendToReport(
//		Dispatch( {}, "weight", ScaleBox, {Scale( "Log" ), Format( "Best", 6 ), Min( 60 ), Max( 200 ), Inc( 1 ), Minor Ticks( 1 )} ),
//		Dispatch( {}, "height", ScaleBox, {Format( "Engineering", 12 )} )
//	)
);

newFormat = {"Percent", "Engineering", "Best"};
newScale = {"Linear", "Log", "Linear"};
newInc = {10, 1, 20};

For( i = 1, i <= N Items( newFormat ), i += 1,
	Wait( 1 ); // wait only needed for the demo!
	gb << Dispatch( {}, "weight", ScaleBox, {Scale( newScale[i] ), Format( "Best", 6 ), 
			Min( 60 ), Max( 200 ), Inc( newInc[i] ), Minor Ticks( 0 )} );
	gb << Dispatch( {}, "height", ScaleBox, {Format( newFormat[i], 12 )} );
);

gb is the platform object that the <<Dispatch message is sent to. Don't send the <<Dispatch message to the report surface. SendToReport(...) is telling the platform object to dispatch messages into the report tree.

Mark suggests using

 

 

gb rep = gb << Report;
gb rep[AxisBox(2)] << Format( Engineering, 12 );

In all of the above, gb is the graph builder platform object. In Mark's example, gb rep is the display box report tree that belongs to the graph builder platform object. Sending the <<report message to the gb platform object retrieves the root of the display box tree (the report surface, the visible part). Subscripting the root returns a more specific subtree of the display box tree:

 

gb rep[AxisBox(2)]

That's what Mark wants to send the Format message to. One way to get that subscript is using Show Tree Structure.

Show Tree Structure: right-click on the open-close triangle.Show Tree Structure: right-click on the open-close triangle.

The report and the tree structure windows are linked; I clicked on the height axis. The height axis and its info in the tree structure both high-lighted. AxisBox(2) is the second axis box in the report.

 

Craige
Highlighted
Lindeman1arr
Level II

Re: dynamically change Dispatch() options sent to GraphBuilder

Thanks Mark, that was very helpful. I have been building the graphs I need in graph builder, then copying the script JMP generates for it and then editing that with my own variables and just not getting it to work. Your solution worked great and helped me understand the process better for all the different changes I want to implement.
Article Labels