cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
EstelleS
Level III

How to embed pre-made scripted graph into Application Builder module?

Hi Everyone,

 

I am scripting in Application Builder. In one of my modules, I have a Graph Box, with the intention of setting it to display a pre-made graph, but I am not having much luck. I was originally thinking that the easiest thing to do would just be to somehow embed my pre-made graph into the module window, so I have been trying to use the Graph Box as a placeholder, trying something like:

graphBox << Visibility("Collapse");
panelBox << Append( /*graph*/ ) );

...but this has not been working. Potentially the easiest way is actually to script the different graph items into the Graph Box individually? I am pretty new to JSL so I know that my approach/syntax must be wrong in some way, but I am not sure what would be the best/easiest way to do this!

 

 

The code to create the graph I want (thanks to helpful users on another question that I posted) is:

Names Default To Here(1);
datafile = Open( "Data.xlsx" );

x_col = Column(datafile, 1);
y_cols = (datafile << Get Column Names())[2::N Cols(datafile)];

var_expr = EvalExpr(
	Variables(X(Expr(x_col))
));

var_line = Expr(Line(X));

For Each({col, idx}, y_cols,
	y_expr = Expr(Y(Position(1)));
	Insert Into(y_expr, NameExpr(col), 1);
	Insert Into(var_expr, Name Expr(y_expr));
	
	yline_expr = Parse("Y("||char(idx)||")");
	Insert Into(var_line, Name Expr(yline_expr));
);

graphbuild = Eval(Substitute(
	Expr(
		graphbuild = datafile << Graph Builder(
			Size(838, 391),
			Show Control Panel(0),
			vvv,
			Elements(yyy)
		)
	),
	Expr(vvv), Name Expr(var_expr),
	Expr(yyy), Name Expr(var_line)
));


/*gb_image = graphbuild << get picture;
graphbuild << Close Window;
New window("time-series plot",
	gb_image
);*/

I commented out the last part of this code, because I actually prefer the resulting graph with the control panel simply suppressed ("Show Control Panel(0)"), as opposed to "<< Get Picture", because this hides the Graph Builder functionalities for the user, but still allows for a dynamic graph (grabbable and moveable axes, etc.). If it is possible to embed the graph in this way, then that is my ideal route.

 

I appreciate any help.

 

Thank you,

Estelle

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to embed pre-made scripted graph into Application Builder module?

Hi Estelle - I'll give one solution that may be helpful for scripting reports whether you are within Application Builder or writing directly in JSL.  When you launch platforms without a containing window, the window is created for you.  A "live" platform can only have one report, so if you try to append a report to an existing window, a copy of the report is created.  This is slightly more interactive than creating a picture, but it is also not what you are looking for.

 

In the example script below, I show three ways to append content to an existing window, and the results have different levels of interactivity:

  1. In the first case, a live Graph Builder platform is embedded directly into an existing window.  The platform does not create another window, and no copying is done.
  2. In the second window, a copy of the report is added, which has less interactivity.  This is a copy of the report by itself, without a platform object.  It has no connection to the data table.
  3. In the third window I append an image of the Graph Builder, which has the least interactivity.
// Create an empty window first
New Window("Interactive Report",
	panel = Panel Box("Interactive Report")
);
Wait(2);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Append a Graph Builder to the existing window
// This report will be entirely interactive
// Axes can be changed, and points can be selected
panel << Append(gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
));

// We could try to create windows from existing platforms
// This will lose some interactivity
// Axes can change, but the selection is fixed
New Window("Report Copy",
	panel2 = Panel Box("Report Copy",
	)
);
Wait(2);
panel2 << Append(Report(gb)); // creates a copy of the report


// Or we could take a picture of the report
// This is the least interactive result - nothing can change
New Window("Report Picture",
	panel3 = Panel Box("Report Picture",
	)
);
Wait(2);
panel3 << Append(gb << Get Picture);

 

Within a JMP Application, you should be able to use any of these approaches.  The first approach would let you append to any box that you have created in the app, just make sure that you run the Graph Builder script within the <<Append(..) message, so that it will embed into the window that you already have.

View solution in original post

1 REPLY 1

Re: How to embed pre-made scripted graph into Application Builder module?

Hi Estelle - I'll give one solution that may be helpful for scripting reports whether you are within Application Builder or writing directly in JSL.  When you launch platforms without a containing window, the window is created for you.  A "live" platform can only have one report, so if you try to append a report to an existing window, a copy of the report is created.  This is slightly more interactive than creating a picture, but it is also not what you are looking for.

 

In the example script below, I show three ways to append content to an existing window, and the results have different levels of interactivity:

  1. In the first case, a live Graph Builder platform is embedded directly into an existing window.  The platform does not create another window, and no copying is done.
  2. In the second window, a copy of the report is added, which has less interactivity.  This is a copy of the report by itself, without a platform object.  It has no connection to the data table.
  3. In the third window I append an image of the Graph Builder, which has the least interactivity.
// Create an empty window first
New Window("Interactive Report",
	panel = Panel Box("Interactive Report")
);
Wait(2);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Append a Graph Builder to the existing window
// This report will be entirely interactive
// Axes can be changed, and points can be selected
panel << Append(gb = dt << Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
	Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
));

// We could try to create windows from existing platforms
// This will lose some interactivity
// Axes can change, but the selection is fixed
New Window("Report Copy",
	panel2 = Panel Box("Report Copy",
	)
);
Wait(2);
panel2 << Append(Report(gb)); // creates a copy of the report


// Or we could take a picture of the report
// This is the least interactive result - nothing can change
New Window("Report Picture",
	panel3 = Panel Box("Report Picture",
	)
);
Wait(2);
panel3 << Append(gb << Get Picture);

 

Within a JMP Application, you should be able to use any of these approaches.  The first approach would let you append to any box that you have created in the app, just make sure that you run the Graph Builder script within the <<Append(..) message, so that it will embed into the window that you already have.