cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
DopeAgonist
Level III

Add ref line in report through application builder script

Hello All,

 I was trying to add the following line in my application builder script to add ref lines to reports:

 

Report1[Axis Box(1)] << Add Ref Line( 100, "Solid", "Medium Dark Red", "LL", 10 );

 

However, it does nothing. I get no warnings or errors in the log. I've checked the display tree and I'm accessing the correct Axis Box. If I change the index of the axis box it does generate an error. I can't see why this shouldn't work. Is this a bug?

 

Strangely, while fiddling with it I changed something that produced an error on that line, but succesfully added the ref line. One time. Rerunning the same thing did not add the line in the future.

 

I have since changed it to a button you press in the report to add the ref line, which worked on the first try using the same exact script line, so I'm not urgently needing a solution. Just wondering if this is a bug.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Add ref line in report through application builder script

I also tried this using Big Class as an example, and I may have figured out what is going on.  My app is attached and it does work initially.  However, if you turn on the Local Data Filter, the line goes away.  The LDF works by rerunning the platform, and in this case the reference line customizations are not retained.  This happens both inside and outside of App Builder.

 

The problem is that platform scripts (as saved from LIRT > Save Script > To Script Window) only save customizations that have been applied since the initial display of the platform.  This is one of the cases where adding the line:

 

Wait(0);

BEFORE the code that accesses the report will allow the platform to display once prior to adding the reference line.  In the attached .jmpappsource I have commented out this line, so you can add it back in to test the solution.

 

View solution in original post

8 REPLIES 8
cwillden
Super User (Alumni)

Re: Add ref line in report through application builder script

How is Report1 defined?  Is that the name of the module?

Typically, to access unnamed display boxes in an Application Builder module window, you need to get a reference to the window using something like: 

Report1 = this module instance << Get box

 Try replacing the line you have with this to see if that is the problem:

(this module instance << get box)[Axis Box(1)] << Add Ref Line( 100, "Solid", "Medium Dark Red", "LL", 10 );

 

 

-- Cameron Willden
DopeAgonist
Level III

Re: Add ref line in report through application builder script

Sorry I didn't provide more context. Report1 is a oneway report allocated in the application builder. The variable does exist.

I was able to access the framebox of the same report to add a legend using:

Report1[FrameBox(1)] << Row Legend(
Tissue,
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 ));


So I think the reference is working.

I did try the line you suggested though and it did not produce anything. No errors or warnings, no ref line.

cwillden
Super User (Alumni)

Re: Add ref line in report through application builder script

Thanks for the clarification.  In that case, your code really should work.  I did a test case with a oneway report in an app builder app, and that line of code worked perfectly.  Maybe it's worth a tech support call?

-- Cameron Willden
Byron_JMP
Staff

Re: Add ref line in report through application builder script

is the goal to add only one reference line, or is the goal to add reference lines dynamically?

Screen Shot 2018-03-08 at 5.51.44 PM.png

 

 

 

 

Sometimes I need to add reference lines based on data in a table. In this case, adding this script to customize the graph toes the trick.

//example
For Each Row( If( :ref > 0, V Line( Row(), Col Minimum( :weight ) - 10, Col Maximum( :weight ) + 10 ) ) )

In a little more context, this is what it looks like.

 

 

dt=open("$Sample_Data\Big Class.jmp");
dt<<	New Column( "ref",
		Set Values(
			[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
		)
	);
dt<<New Column( "Row",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Row() )
	),

dt<<Graph Builder(
	Size( 528, 446 ),
	Show Control Panel( 0 ),
	Variables( X( :Row ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Add Graphics Script(
				2,
				Description( "Script" ),
				For Each Row(
					If( :ref > 0,
						V Line(
							Row(),
							Col Minimum( :weight ) - 10,
							Col Maximum( :weight ) + 10
						)
					)
				)
			), Grid Line Order( 1 ), Reference Line Order( 3 )}
		)
	)
);
JMP Systems Engineer, Health and Life Sciences (Pharma)

Re: Add ref line in report through application builder script

I also tried this using Big Class as an example, and I may have figured out what is going on.  My app is attached and it does work initially.  However, if you turn on the Local Data Filter, the line goes away.  The LDF works by rerunning the platform, and in this case the reference line customizations are not retained.  This happens both inside and outside of App Builder.

 

The problem is that platform scripts (as saved from LIRT > Save Script > To Script Window) only save customizations that have been applied since the initial display of the platform.  This is one of the cases where adding the line:

 

Wait(0);

BEFORE the code that accesses the report will allow the platform to display once prior to adding the reference line.  In the attached .jmpappsource I have commented out this line, so you can add it back in to test the solution.

 

DopeAgonist
Level III

Re: Add ref line in report through application builder script

Thanks as usual everyone!!

 

Dan, can you explain what exactly adding the Wait(0); line does? (i.e. update the displays?)

Re: Add ref line in report through application builder script

In this case Wait(0) allows the window to display to the screen, which also sets the "initial state" that determines whether customizations are saved to the script.  For performance reasons, some events are processed asynchronously to allow scripts to continue to run.

Re: Add ref line in report through application builder script

Hi everyone - i am happy to report that the original issue reported here has been fixed in the latest release of JMP (15). You should no longer need the wait(0) for this to work. For those who are using older versions of JMP, this is a great workaround.