cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar
miguello
Level VII

Can't change FrameBox size when creating report - only when all display boxes AND window created.

All, 

 

I have a script with function that creates a GraphBuilder. It then gets packed into display boxes and put into a new window. Somehow, commands to change FrameBox size from within the function are ignored, and I can only change it when window is created. Why is that? I'd like this functionality to be inside the function, so that it outputs a plot that does not need any additional tinkering with. Changing title works from within the function, why not changing size?

 

Here's an example with 3 different attempts to change FrameBox size - only the third one works.

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
X_Parameter = "height";
Y_Parameter = "weight";
groupColumn = "sex";
titleText = "Example";


GBfunction= Function( {dt, X_parameter, Y_Parameter, groupByColumnString, titleText = ""},
	groupByColumn = Column( dt, groupByColumnString );
	cb = Context Box(
		gb = Graph Builder(
			Size( 350, 600 ),
			Ignore Platform Preferences( 1 ),
			Show Control Panel( 0 ),
			Variables( X( Column( X_Parameter ) ), Y( Column( Y_Parameter ) ), Overlay( groupByColumn ) ), 

		);
	
		rgb = gb << Report;
		(rgbOB = ((rgb << XPath( "//OutlineBox[@helpKey = 'Graph Builder']" ))[1])) << Set Title( titleText );
		//Attempt #1
		(rgb << XPath( "(//OutlineBox//FrameBox)" )) << Frame Size( 350, 200 );
		//Attempt #2
		//(rgbOB << XPath( "//FrameBox" )) << Frame Size( 350, 200 );
	
	);
	Return( cb );
);

lub = Lineup Box( N Col( 3 ) );
lub << Append( GBfunction( dt, X_Parameter, Y_Parameter, groupColumn, titleText ) );
ob_group = Outline Box( "GB Function example: " || (dt << Get Name) );
ob_group << Append( lub );
nw = New Window( (dt << get name), ob_group );

//Attempt #3
rgb = ob_group << XPath( "//OutlineBox[@helpKey='Graph Builder']" );
//(rgb << XPath( "(//OutlineBox//FrameBox)" )) << Frame Size( 350, 200 );
7 REPLIES 7
jthi
Super User

Re: Can't change FrameBox size when creating report - only when all display boxes AND window created.

I think changing the frame size doesn't work properly as the frame hasn't yet been visualized, some auto-resizing does take over and there can potentially also be some timing issues.

-Jarmo
miguello
Level VII

Re: Can't change FrameBox size when creating report - only when all display boxes AND window created.

I tried setting auto stretching to 0 and stretching to none, obviously, didn't help

jthi
Super User

Re: Can't change FrameBox size when creating report - only when all display boxes AND window created.

Figuring out what is forcing the size to be something weird is not always easy. Is there a specific reason why you aren't utilizing Graph Builder's << Size? I know that sometimes it can require some pre-calculations for example when using groups or wrapping

View more...
Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
X_Parameter = "height";
Y_Parameter = "weight";
groupColumn = "sex";
titleText = "Example";


GBfunction = Function({dt, X_parameter, Y_Parameter, groupByColumnString, titleText = ""}, {Default Local},
	groupByColumn = Column(dt, groupByColumnString);
	cb = Context Box(
		gb = dt << Graph Builder(
			Size(100, 100),
			Ignore Platform Preferences(1),
			Show Control Panel(0),
			//Fit To Window("Off"),
			Variables(
				X(Column(X_Parameter)), 
				Y(Column(Y_Parameter)), 
				Overlay(groupByColumn)
			),
		);
	);
	
	rgb = Report(gb);
	(rgbOB = ((rgb << XPath("//OutlineBox[@helpKey = 'Graph Builder']"))[1])) << Set Title(titleText);
	fbs = rgb << XPath("(//OutlineBox//FrameBox)");
	gb << Size(400, 250);
	
	Return(cb);
);

lub = Lineup Box(N Col(3));
lub << Append(GBfunction(dt, X_Parameter, Y_Parameter, groupColumn, titleText));
ob_group = Outline Box("GB Function example: " || (dt << Get Name));
ob_group << Append(lub);
nw = New Window((dt << get name), ob_group);
-Jarmo
miguello
Level VII

Re: Can't change FrameBox size when creating report - only when all display boxes AND window created.

Yes, there is a reason - I need to mimic the same look and feel that I had in previous iterations of the script that utilized Fit Y by X. 

GraphBuilder will change FrameBox size depending on other elements in GB display box - Axis or Legend size, for instance. 

 

At the end these plots will go to a report where the size of the graph area (what exactly the FrameBox is) should be consistent between different plots on the report. That's why.

jthi
Super User

Re: Can't change FrameBox size when creating report - only when all display boxes AND window created.

One option could be to create the new window first

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
X_Parameter = "height";
Y_Parameter = "weight";
groupColumn = "sex";
titleText = "Example";


GBfunction = Function({lub, dt, X_parameter, Y_Parameter, groupByColumnString, titleText = ""}, {Default Local},
	cb = Context Box(
		gb = dt << Graph Builder(
			Size(600, 600),
			Ignore Platform Preferences(1),
			Show Control Panel(0), 
			Fit To Window("Off"),
			Variables(X(Eval(X_Parameter)), Y(Eval(Y_Parameter)), Overlay(Eval(groupByColumnString))),

		)
	);
	
	rgb = Report(gb);
	lub << Append(cb);
	
	(rgbOB = ((rgb << XPath("//OutlineBox[@helpKey = 'Graph Builder']"))[1])) <<
	Set Title(titleText);
	fbs = rgb << XPath("(//OutlineBox//FrameBox)");
	fbs << Frame Size(400, 250);
);

lub = Lineup Box(N Col(3));
ob_group = Outline Box("GB Function example: " || (dt << Get Name));
ob_group << Append(lub);
nw = New Window((dt << get name), Window View("Invisible"), ob_group);

GBfunction(lub, dt, X_Parameter, Y_Parameter, groupColumn, titleText);
nw << Show Window(1);

 

-Jarmo
miguello
Level VII

Re: Can't change FrameBox size when creating report - only when all display boxes AND window created.

You example works as written. However, when I try to implement it in my real-life script, it does resize the FrameBox from Size(350, 600) to something else at the end.

 

Basically, I have LineUpBox for a reason - I generate several plots in that box, and every third one (or to be precise, every rightmost in each row) has Legend displayed (same for all plots). So when I run it with three plots, the final size of all three FrameBoxes ends up being:

{{350, 220}, {350, 220}, {350, 240}}

instead of {350, 200} that I am trying to resize it to or the initial {350, 600} that GraphBuilder made it with.

 

I'll try to make a working example that breaks your suggestion later on.

 

ErraticAttack
Level VI

Re: Can't change FrameBox size when creating report - only when all display boxes AND window created.

This has been a bug forever with GraphBuilder, and there is no easy work-around.  I have an external program that can send notifications back to JMP (it's a localhost server that JMP starts with runcommand) and I feed it a message to ping JMP back in 0.25 seconds, and on that pingback I trigger the forcing of the framesize -- which now occurs after the boxes have all been painted.

Jordan

Recommended Articles