cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
] />

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
miguello
Level VII

Need help troubleshooting graphics script: "Graphic script reported errors in log"

I need help understanding how to reference framebox's axis from within graphics script.

Here's what I have now:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
ob_group = Outline Box( "Testing Handles: " || (dt << Get Name) );

nw = New Window( (dt << get name), ob_group );

GB_wHandle = Function( {dt, X_parameter, Y_Parameter, groupByColumnString},
	groupByColumn = Column( dt, groupByColumnString );
	cb = Context Box(
		box:exx = 60;
		box:exy = 60;
		box:gb = Graph Builder(
			Size( 450, 350 ),
			Ignore Platform Preferences( 1 ),
			Show Control Panel( 0 ),
			Variables( X( Column( X_Parameter ) ), Y( Column( Y_Parameter ) ), Overlay( groupByColumn ) ),
			Elements( Points( X, Y ), Smoother( X, Y ) )
		);
		box:rgb = box:gb << Report;


		box:framebox = box:rgb << XPATH( "//FrameBox" );

		box:axis = box:rgb << XPATH( "//AxisBox" );
		box:axisMax = box:axis << Get Max;
		box:axisMin = box:axis << Get Min;
		
		{box:exx, box:exy} = box:axisMin + 10;
		
		box:framebox << Add Graphics Script(
			"Front",
			Description( "Handle" ), 
			
			//Script start
			{Handle(
				box:exx,
				box:exy,
				box:exx = x;
				box:exy = y;
			) ; 
			box:axisMax = box:axis << Get Max;
			box:axisMin = box:axis << Get Min;
			Pen Color( "Red" ) ; Line( box:axisMin, {box:exx, box:exy} ) ; }
		);
	);
	Return( cb );
);

ob_group << Append( GB_wHandle( dt, "height", "weight", "sex" ) );

I need context box because I have multiple GBs in the same window with independent handles.

Everything works until I select a point on the plot or a row in the table and exclude it.

Then my graphics disappear and I get "Graphic script reported errors in log" and "Send Expects Scriptable Object in access or evaluation of 'List' , {/*###*/DisplayBox[], DisplayBox[]}" in the log.

The error happens because of the lines:

box:axisMax = box:axis << Get Max;
box:axisMin = box:axis << Get Min;

If I comment them out, no errors - but then I don't get updated axis min/max in case user changes axis scale.

 

How can I fix it?

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

One way to fix this could be to add

box:axis = box:rgb << XPATH("//AxisBox");

to your graphic script

-Jarmo

View solution in original post

10 REPLIES 10
jthi
Super User

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

This demonstrates the problem in much simpler manner

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
ob_group = Outline Box("Testing Handles: " || (dt << Get Name));

gb = dt << Graph Builder(
	Size(450, 350),
	Ignore Platform Preferences(1),
	Show Control Panel(0),
	Variables(X(Column("height")), Y(Column("weight")), Overlay("sex")),
	Elements(Points(X, Y), Smoother(X, Y))
);

fbs = Report(gb) << XPATH("//FrameBox");
abs = Report(gb) << XPATH("//AxisBox");
show(fbs, abs);

dt << Select Rows(1) << Hide and Exclude(1) << Clear Select;
wait(1);

show(fbs, abs);

When you are excluding the rows, graph builder is being recalculated and your references get deleted.

-Jarmo
jthi
Super User

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

One way to fix this could be to add

box:axis = box:rgb << XPATH("//AxisBox");

to your graphic script

-Jarmo
miguello
Level VII

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

Yep, it worked. For some reason I thought I wouldn't be able to reference report from within the script.

miguello
Level VII

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

@jthi , one more question.
Let's say I want to wrap adding graphics script into a function, that would add that script to a Graph Builder.
This function would only need to take in a reference a Display Box then to find the corresponding Framebox and add the script.

Right now in my function I have to wrap Graph Builder in Context Box, so that the elements I create (handle specifically) using  this script are independent from other ones in other Graph Builders in the same window.

Question - What display box should I provide to the function to save the isolated context? In XML I see there is EvalContextBox - is this what was generated by "Context Box"?

What would be the syntaxis within function? Since function is not going to have Context Box, I'll have to drop "box" namespace. How do I limit the context in this case?

 

jthi
Super User

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

I'm a bit confused about what you wish to pass to the function, just a reference to the graph builder? Would the graph builder still be inside context box?

-Jarmo
miguello
Level VII

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

That is one of the question I have - what SHOULD I pass to the function and if I still NEED the Context Box in this case.

Right now my script is structured the following way:

//Preparing display boxes structure and window
lub = Lineup Box( N );
ob_group = Outline Box( "Report: " || (dt << Get Name) );
ob_group << Append( lub );

nw = New Window( (dt << get name), Window View("Invisible"), ob_group );

Then I work with the data table to select what I want to plot etc., and use this function to make Context Box with Graph Builder inside, returning Context Box:

GB_func = Function( {dt, X_parameter, Y_Parameter...}, 
	cb = Context Box(
		gb = Graph Builder(...
			//<graph builder code>
		);

		box:rgb = gb << Report;
		//Doing some other stuff

		//Adding Graphics Script
		box:framebox = box:rgb << XPATH( "//FrameBox" );
		box:framebox << Add Graphics Script(...)
		
	Return( cb );
);		
		
			

Then I take whatever columns I need to plot, and for each make those Context Boxes with Graph Builder platform inside:

For Each( {Y_Parameter, index}, Y_Parameters,
lub << Append( GB_func( dt, X_Parameter, Y_Parameter));
);

What I want is a function that I can pass whatever display box or reference needed for each separate Graph Builder and it would add the same graphics script that would work the same way it's working now - independent of other Graph Builders.

End goal is to be able to turn the additional graphics on the plot on/off through Graph Builder Context Menu - there are use cases for both with\without graphics. Removing graphics script is not a problem AFAIK, trying to figure out how to add one in this case.

 

 

 

 

 

jthi
Super User

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

Context Box is most likely the easiest to pass. You could also store the "global" values in some namespace which isn't box (here, window, global, named, anonymous, ...) in which case you could drop context box and pass in the graph builder reference.

-Jarmo
miguello
Level VII

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

What is the Display Box that Context Box makes? Is it EvalContextBox? How do I say that the variables that are inside the graphics script should only be scoped within that EvalContextBox? Just use box namespace? Or there is a way to get the namespace reference associated with EvalContextBox?

jthi
Super User

Re: Need help troubleshooting graphics script: "Graphic script reported errors in log"

You can use Namespace()

Names Default To Here(1);

nw = New Window("",
	Context Box(
		box:var = "",
		box:tb = Text Edit Box("AA", <<Set Function(Function({this},
			box:var = this << get text;
		)))
	)
);

Show(Namespace(nw[EvalContextBox(2)]):var);

Change the text edit box value and run the last line again.

-Jarmo

Recommended Articles