Choose Language Hide Translation Bar
Highlighted
herbie226
Community Trekker

New to JMP Scripting - want to know how to set a loop for Graph Builder Dispatch/ScaleBox

Hello, I am attempting to add variables to my Graph Builder script so that I can loop through a number of charts and format them all the same.

Can anyone help me with setting the variables correcltly? Not sure where I am going wrong and cannot find a similar example online. Appreciate any help you can provide.

 

Thanks!

 

 

Graph Builder(
	Size( 1081, 4190 ),
	Variables(
		X( :StartTime ),
		Y( :Chamber Opened RFH, Side( "Right" ) ),
		Y( :DP RFH, Position( 1 ), Side( "Right" ) ),
		Y( :FR RFH, Position( 1 ), Side( "Right" ) ),
		Y( :Upper Wall RFH, Position( 1 ), Side( "Right" ) ),
		Y( :Wet Clean RFH, Position( 1 ), Side( "Right" ) ),
		Y( :Name( "Step_Duration-19StepValue" ), Position( 1 ) ),
		Page( :Tool_Chamber ID )
	),
	
	Elements(Points( X, Y( 6 ), Legend( 5 ) ),Line( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Y( 5 ), Legend( 7 ) )),
	SendToReport(
		

		For (i=2, i<=11, i++,
			
			Dispatch({},"StartTime",ScaleBox( Expr(i) ),{Format( "m/d/y", 10 ), Min( 3586118400 ), Max( 3597955200 ),
				Interval( "Month" ), Inc( 1 ), Minor Ticks( 0 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )}),
			Dispatch({},"Step_Duration-19StepValue",ScaleBox( Expr(i) ),{Min( 40 ), Max( 50 ), Inc( 0.5 ), Minor Ticks( 1 ),
			Add Ref Line( 48, "Dashed", "Medium Dark Red", "Max (48sec)", 2 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )}	),
			);
		
		
		For (i=1, i<=10, i++,
			Dispatch({},"Chamber Opened RFH",ScaleBox( Expr(j) ),{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 610.353515625 ), Inc( 50 ),Minor Ticks( 0 ), Label Row({Set Font Size( 14 ), Set Font Style( "Bold" )})}),
			Dispatch( {}, "X title", Text Edit Box( Expr(j) ), {Set Text( "" )} ),
			Dispatch( {}, "Y title", Text Edit Box( Expr(j) ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "SL Step 19 EPD (sec)" )} ),
			Dispatch( {}, "Y r title", Text Edit Box( Expr(j) ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "RF Hrs" )} ),
			);
		
		Dispatch( {}, "400", LegendBox,	{Legend Position( {5, [0], 7, [1, 2, 3, 4, 5]} ), Position( {0, 1, 2, 3, 4, 5} )})
	)
);

 

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
ih
ih
Community Trekker

Re: New to JMP Scripting - want to know how to set a loop for Graph Builder Dispatch/ScaleBox

Give this a try:

Names default to here( 1 );

dt = Open( "$Sample_data/Australian Tourism.jmp" );

gb = dt << Graph Builder(
	Size( 457, 6762 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Date ),
		Y( :Persons Employed, Side( "Right" ) ),
		Y( :Name( "Guest arrivals ('000)" ), Position( 1 ), Side( "Right" ) ),
		Y( :Rooms, Position( 1 ) ),
		Page( :Year )
	),
	Elements(
		Points( X, Y( 3 ), Legend( 71 ) ),
		Smoother( X, Y( 3 ), Legend( 72 ) ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 73 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Legend( 74 ) )
	)
);

For( i=2, i<=15, i++,
	gb << SendToReport(
		Dispatch(
			{},
			"Date",
			ScaleBox( i ),
			{Min( 2934921600 ), Max( 3597609600 ), Interval( "Year" ), Inc( 1 ),
			Minor Ticks( 3 ), Label Row( Show Major Grid( 1 ) )}
		),
		Dispatch(
			{},
			"Rooms",
			ScaleBox( i ),
			{Min( 70000 ), Max( 73000 ), Inc( 500 ),
			Minor Ticks( 1 )}
		),
		Dispatch(
			{},
			"Persons Employed",
			ScaleBox( i ),
			{Min( -60000 ), Max( 80000 ), Inc( 10000 ),
			Minor Ticks( 0 )}
		),
		Dispatch( {}, "X title", Text Edit Box( i - 1 ), {Set Text( "X Axis" )} ),
		Dispatch( {}, "Y title", Text Edit Box( i - 1 ), {Set Text( "Left Y Axis" )} ),
		Dispatch( {}, "Y r title", Text Edit Box( i -1  ), {Set Text( "Right Y Axis" )} )
	)
);

View solution in original post

5 REPLIES 5
cwillden
Super User

Re: New to JMP Scripting - want to know how to set a loop for Graph Builder Dispatch/ScaleBox

First thing I notice is that you name the indexing variable "i" in both loops, but refer to an index variable "j" in the second.

I'm guessing you can get what you need without scripting by formatting everything to your liking before dropping :Tool_Chamber ID into the Page dropzone.  That should propogate the original formatting to each page.

It's a little difficult to diagnose the issue without the data table you are using.  The bottom portion of the Graph Builder script is a little hard to follow.  If my advice doesn't help you, can you post an example of what you want to do with one of JMP's sample data sets or a dummy one that you create?  Also, the log would be helpful (Ctrl+Shift+L or View > Log).

-- Cameron Willden
0 Kudos
herbie226
Community Trekker

Re: New to JMP Scripting - want to know how to set a loop for Graph Builder Dispatch/ScaleBox

Hello,
Yes, i noticed the i vs j variable but this doesn't help how the graphs are generated. As written, I only get formatting for part of one plot. All the others remain formatted. Since I have many plots to generate (in a similar format) with varying information needed to for each plot, understanding how the variables work is needed to complete my goals. I appreciate your suggestion, but I will need a working solution for incorporating a loop into the formatting process.
Thank you for your feedback :)
0 Kudos
herbie226
Community Trekker

Re: New to JMP Scripting - want to know how to set a loop for Graph Builder Dispatch/ScaleBox

Here are some additional iterations I have tried... Some are commented out. None of them will work... ugh...

 

dt = currentdatatable();

Graph Builder(
Size( 1081, 4190 ),
Variables(
X( :StartTime ),
Y( :Chamber Opened RFH, Side( "Right" ) ),
Y( :DP RFH, Position( 1 ), Side( "Right" ) ),
Y( :FR RFH, Position( 1 ), Side( "Right" ) ),
Y( :Upper Wall RFH, Position( 1 ), Side( "Right" ) ),
Y( :Wet Clean RFH, Position( 1 ), Side( "Right" ) ),
Y( :Name( "Step_Duration-19StepValue" ), Position( 1 ) ),
Page( :Tool_Chamber ID )
),

Elements(Points( X, Y( 6 ), Legend( 5 ) ),Line( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Y( 5 ), Legend( 7 ) )),


List= {"1","2","3","4","5","6","7","8","9","10"};
nList = N Items(List);

For (i=1,i <= nList, i++,

gb= Expr( SendToReport(
Dispatch({},"StartTime",ScaleBox( List[i]+1 ),{Format( "m/d/y", 10 ), Min( 3586118400 ), Max( 3597955200 ),
Interval( "Month" ), Inc( 1 ), Minor Ticks( 0 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )}),
Dispatch({},"Step_Duration-19StepValue",ScaleBox( List[i]+1 ),{Min( 40 ), Max( 50 ), Inc( 0.5 ), Minor Ticks( 1 ),
Add Ref Line( 48, "Dashed", "Medium Dark Red", "Max (48sec)", 2 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )} ),
Dispatch({},"Chamber Opened RFH",ScaleBox( List[i] ),{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 610.353515625 ), Inc( 50 ),Minor Ticks( 0 ), Label Row({Set Font Size( 14 ), Set Font Style( "Bold" )})}),
Dispatch( {}, "X title", Text Edit Box( List[i] ), {Set Text( "" )} ),
Dispatch( {}, "Y title", Text Edit Box( List[i] ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "SL Step 19 EPD (sec)" )} ),
Dispatch( {}, "Y r title", Text Edit Box( List[i] ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "RF Hrs" )} ),
)
);
Eval(Substitute(Name Expr(gb),Expr(List[i]),List[i]));
);







/*List= {"1","2","3","4","5","6","7","8","9","10"};
nList = N Items(List);

For (i=1,i <= nList, i++,

gb= dt << SendToReport(
Dispatch({},"StartTime",ScaleBox( List[i]+1 ),{Format( "m/d/y", 10 ), Min( 3586118400 ), Max( 3597955200 ),
Interval( "Month" ), Inc( 1 ), Minor Ticks( 0 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )}),
Dispatch({},"Step_Duration-19StepValue",ScaleBox( List[i]+1 ),{Min( 40 ), Max( 50 ), Inc( 0.5 ), Minor Ticks( 1 ),
Add Ref Line( 48, "Dashed", "Medium Dark Red", "Max (48sec)", 2 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )} ),
Dispatch({},"Chamber Opened RFH",ScaleBox( List[i] ),{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 610.353515625 ), Inc( 50 ),Minor Ticks( 0 ), Label Row({Set Font Size( 14 ), Set Font Style( "Bold" )})}),
Dispatch( {}, "X title", Text Edit Box( List[i] ), {Set Text( "" )} ),
Dispatch( {}, "Y title", Text Edit Box( List[i] ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "SL Step 19 EPD (sec)" )} ),
Dispatch( {}, "Y r title", Text Edit Box( List[i] ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "RF Hrs" )} ),);

Eval(Eval Expr(gb));
);*/


/*For (i=1, i<=10, i++,

gb= dt << SendToReport(
Dispatch({},"StartTime",ScaleBox( eval(i)+1 ),{Format( "m/d/y", 10 ), Min( 3586118400 ), Max( 3597955200 ),
Interval( "Month" ), Inc( 1 ), Minor Ticks( 0 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )}),
Dispatch({},"Step_Duration-19StepValue",ScaleBox( eval(i)+1 ),{Min( 40 ), Max( 50 ), Inc( 0.5 ), Minor Ticks( 1 ),
Add Ref Line( 48, "Dashed", "Medium Dark Red", "Max (48sec)", 2 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )} ),
Dispatch({},"Chamber Opened RFH",ScaleBox( eval(i) ),{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 610.353515625 ), Inc( 50 ),Minor Ticks( 0 ), Label Row({Set Font Size( 14 ), Set Font Style( "Bold" )})}),
Dispatch( {}, "X title", Text Edit Box( eval(i) ), {Set Text( "" )} ),
Dispatch( {}, "Y title", Text Edit Box( eval(i) ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "SL Step 19 EPD (sec)" )} ),
Dispatch( {}, "Y r title", Text Edit Box( eval(i) ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "RF Hrs" )} ),);

Eval(Eval Expr(gb));
);*/


/*List= {"1","2","3","4","5","6","7","8","9","10"};
i=1;
gb= Expr( SendToReport(
Dispatch({},"StartTime",ScaleBox( List[i]+1 ),{Format( "m/d/y", 10 ), Min( 3586118400 ), Max( 3597955200 ),
Interval( "Month" ), Inc( 1 ), Minor Ticks( 0 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )}),
Dispatch({},"Step_Duration-19StepValue",ScaleBox( List[i]+1 ),{Min( 40 ), Max( 50 ), Inc( 0.5 ), Minor Ticks( 1 ),
Add Ref Line( 48, "Dashed", "Medium Dark Red", "Max (48sec)", 2 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )} ),
Dispatch({},"Chamber Opened RFH",ScaleBox( List[i] ),{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 610.353515625 ), Inc( 50 ),Minor Ticks( 0 ), Label Row({Set Font Size( 14 ), Set Font Style( "Bold" )})}),
Dispatch( {}, "X title", Text Edit Box( List[i] ), {Set Text( "" )} ),
Dispatch( {}, "Y title", Text Edit Box( List[i] ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "SL Step 19 EPD (sec)" )} ),
Dispatch( {}, "Y r title", Text Edit Box( List[i] ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "RF Hrs" )} ),
)
);
Eval(Substitute(Name Expr(gb),Expr(List[i]),List[i]));*/


/*Expr(
gb= dt << SendToReport(
Dispatch({},"StartTime",ScaleBox( eval(i)+1 ),{Format( "m/d/y", 10 ), Min( 3586118400 ), Max( 3597955200 ),
Interval( "Month" ), Inc( 1 ), Minor Ticks( 0 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )}),
Dispatch({},"Step_Duration-19StepValue",ScaleBox( eval(i)+1 ),{Min( 40 ), Max( 50 ), Inc( 0.5 ), Minor Ticks( 1 ),
Add Ref Line( 48, "Dashed", "Medium Dark Red", "Max (48sec)", 2 ),Label Row( {Set Font Size( 14 ), Set Font Style( "Bold" )} )} ),
Dispatch({},"Chamber Opened RFH",ScaleBox( eval(i) ),{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 610.353515625 ), Inc( 50 ),Minor Ticks( 0 ), Label Row({Set Font Size( 14 ), Set Font Style( "Bold" )})}),
Dispatch( {}, "X title", Text Edit Box( eval(i) ), {Set Text( "" )} ),
Dispatch( {}, "Y title", Text Edit Box( eval(i) ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "SL Step 19 EPD (sec)" )} ),
Dispatch( {}, "Y r title", Text Edit Box( eval(i) ), {Set Font Size( 14 ), Set Font Style( "Bold" ), Set Text( "RF Hrs" )} ),)
);


For (i=1, i<=10, i++,
Wait(1);
//Eval(Eval Expr(gb));

Eval(substitute(nameexpr(gb),Expr(gb),i));

);*/




Dispatch( {}, "400", LegendBox, {Legend Position( {5, [0], 7, [1, 2, 3, 4, 5]} ), Position( {0, 1, 2, 3, 4, 5} )})
);

 

0 Kudos
ih
ih
Community Trekker

Re: New to JMP Scripting - want to know how to set a loop for Graph Builder Dispatch/ScaleBox

Give this a try:

Names default to here( 1 );

dt = Open( "$Sample_data/Australian Tourism.jmp" );

gb = dt << Graph Builder(
	Size( 457, 6762 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Date ),
		Y( :Persons Employed, Side( "Right" ) ),
		Y( :Name( "Guest arrivals ('000)" ), Position( 1 ), Side( "Right" ) ),
		Y( :Rooms, Position( 1 ) ),
		Page( :Year )
	),
	Elements(
		Points( X, Y( 3 ), Legend( 71 ) ),
		Smoother( X, Y( 3 ), Legend( 72 ) ),
		Points( X, Y( 1 ), Y( 2 ), Legend( 73 ) ),
		Smoother( X, Y( 1 ), Y( 2 ), Legend( 74 ) )
	)
);

For( i=2, i<=15, i++,
	gb << SendToReport(
		Dispatch(
			{},
			"Date",
			ScaleBox( i ),
			{Min( 2934921600 ), Max( 3597609600 ), Interval( "Year" ), Inc( 1 ),
			Minor Ticks( 3 ), Label Row( Show Major Grid( 1 ) )}
		),
		Dispatch(
			{},
			"Rooms",
			ScaleBox( i ),
			{Min( 70000 ), Max( 73000 ), Inc( 500 ),
			Minor Ticks( 1 )}
		),
		Dispatch(
			{},
			"Persons Employed",
			ScaleBox( i ),
			{Min( -60000 ), Max( 80000 ), Inc( 10000 ),
			Minor Ticks( 0 )}
		),
		Dispatch( {}, "X title", Text Edit Box( i - 1 ), {Set Text( "X Axis" )} ),
		Dispatch( {}, "Y title", Text Edit Box( i - 1 ), {Set Text( "Left Y Axis" )} ),
		Dispatch( {}, "Y r title", Text Edit Box( i -1  ), {Set Text( "Right Y Axis" )} )
	)
);

View solution in original post

herbie226
Community Trekker

Re: New to JMP Scripting - want to know how to set a loop for Graph Builder Dispatch/ScaleBox

boom town! Kudos to you :)
0 Kudos