cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
mikedriscoll
Level VI

HTML-like references within a JSL scripted display window

Hi, I have a script that does an analysis on a given data set, and outputs summaries on the first few pages of a report (uses new window() command with various display objects), followed by N pages of scripted analysis for N chosen parameters. All of this is in the same report, and I make use of the page break feature to separate each parameter. N can be any number... just a few or a thousand or so parameters / pages.  Is it possible to have hyperlinks that can link from the summary on the first page or so and point to targets within this report? It could point to either a coded target, or a page number, which i could try to track.  Coded reference is preferred... with 1000 parameters the summary would wrap through several pages and I'm actually not sure I could keep track of page number.

I've seen links (e.g. help menu -> sample data -> all categories have them), but they would point to a file or I suppose some other protocol address would also work -- open() vs web() commands.  But is it possible to code it such that I can link and point to a place in the same report window?

Note that because I make extensive use of dynamically controlled / scaled axis boxes and on the fly calculations, it needs to be done in the native 'new window()' output, not an HTML5 export.

Thanks,
Mike

1 ACCEPTED SOLUTION

Accepted Solutions

Re: HTML-like references within a JSL scripted display window

Mike,

The earlier TabBox() example should save as you want in PDF, but that doesn't offer the long report you are looking for.  So here is another option for you.  See the embedded comments for details.

Wendy


dt = Open( "$SAMPLE_DATA\Fitness.jmp" );


colList = dt << Get Column Names( Continuous, String );



/* New Window with a Summary OutlineBox and a separate Analyses OutlineBox */


nw = New Window( "Example 2", ob = Outline Box( "Summary" ), Outline Box( "Analyses", vl = V List Box() ) );


/* Initialize a list for storing references to the Distributions */


dist = {};



/* Loop through each column


     - append each Distribution to the Analyses Outline Box


     - append a button link to expand the specified Distribution OutlineBox */


For( i = 1, i <= N Items( colList ), i++,


       vl << Append( dist = Distribution( Continuous Distribution( Column( Column( colList ) ), Horizontal Layout( 1 ), Vertical( 0 ) ) ) );


       var = colList || " Distribution";


       Report( dist )[Outline Box( 1 )] << Set Title( var );


       Eval(


              Eval Expr(


                     ob << Append(


                           bb = Button Box( var,


                                  Current Window()[Expr( var )] << Close All Like This;


                                  Current Window()[Expr( var )] << Set Open( 1 );


                           )


                     )


              )


       );


       bb << UnderlineStyle( 1 );


);



/* Add a button to open all the OutlineBoxes and save the output as PDF */


ob << Append(


       Button Box( "Save All to PDF",


              Current Window()["Analyses"] << Open All Below;


              Current Window() << Set Page Setup( Scale(.75));


              path = Pick File( "Select PDF File", "E:\Trash", {"PDF|pdf"}, 1, 1, "Example 2.pdf" );


              Current Window() << SavePDF( path );


              Open( path );


       )


);



Wendy

View solution in original post

7 REPLIES 7

Re: HTML-like references within a JSL scripted display window

Hi, Mike.

Have you considered using TabBox()?  There is a tab style called "Combo" that produces a dropdown menu of each tab name so the user can select and be taken to that tab directly.  Here is a simple example:


/* Open sample data and obtain a list of column names */


dt = Open( "$SAMPLE_DATA\Fitness.jmp" );


colList = dt << Get Column Names( Continuous, String );





/* Store the number of desired tabs in a variable */


nTabs = N Items( colList );





/* Create a New Window containing an empty TabBox */


New Window( "Example", tb = Tab Box() );





/* Use a For loop to add the desired number of tabs to the TabBox */


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


  tb << Add( colList || " Distribution",


      V List Box(


          Distribution( Continuous Distribution( Column( Column( colList ) ), Horizontal Layout( 1 ), Vertical( 0 ) ) )


      )


  )


);


tb << Set Selected( 1 );


tb << Set Style( "combo" );


Wendy
mikedriscoll
Level VI

Re: HTML-like references within a JSL scripted display window

Hi Wendy,

I've been thinking along those lines as a workaround, but I like the idea of keeping the full set of parameters in 1 very long report for report archiving. I can print to pdf for someone (or very likely, no one) to view it later. Also, with 1000+ parameters, sometimes it is nice to be able to quickly page down and just visually scan for a distribution that looks off (skewed, bi modal, outliers). 

My idea was to create the same window i have now, but also open a separate window the first time a link (parameter name) in the summary was clicked. In this window would be a set of analyses and outputs that are essentially the same as i have in my main window, except that in the secondary window it would just be 1 parameter, while in the main window, it would be the full set of many parameters. Clicking on subsequent links from the main window would delete the previous parameter from the secondary window and create the new one.  There are several radio buttons and other controls and axis scaling that is done, so I'd have to take this information and relay it back to the main window's corresponding parameter, but it would probably work.  The only exception I think would be manually scaling the axis with the mouse.  I don't think there is an event function that is associated with this  (OnAxisChange() for example), but I suppose a 'done' button could be implemented to grab the new min / max and throw that back into the main window's parameter's axis.

Thanks,
Mike

Jeff_Perkinson
Community Manager Community Manager

Re: HTML-like references within a JSL scripted display window

I think I would use Column Switcher in a case like this.

It will allow your user to pick the analysis they want, no extra scripting on your part to update another window.

If you want the PDF option you can put a button on the window that will run all the parameters in a new, invisible window and save it as PDF.

-Jeff

-Jeff
mikedriscoll
Level VI

Re: HTML-like references within a JSL scripted display window

Hi Jeff,

I spent some time checking the column switcher out. Someone at the Discovery Summit had mentioned it (shortly after your game show host stint ), but I didn't realize it can be added to any platform.   I really like the play / vary speed feature. However, my script has some other embedded features, one of which is allowing the user to scale window size on distributions using radio buttons (application is semiconductor electrical testing in production). I have a button to scale all parameters' axes to existing limits (and others window sizes like all data, low side fallout, high side fallout, median +/- N * IQR, etc). Keeping these min / max values as the user sets them is important; it looks like column switcher resets this.  Other features include ability to group-by using Anova and GR&R all at the same time.

But for this specific feature I use, I set all the min / max axes to the corresponding spec limits. This means the only part of the distribution shown is from the minimum limit to max limit (min / max spec in our testing); this is used as a starting point such that all parameters start with min / max of the window = min / max spec limit.  Each individual parameter has these axis scaling controls as well, or a user can use the mouse to scale the axis.  After the user goes in and scales the parameters of interest, there is a button at the bottom to generate a limit table. This grabs all of the min / max axis values and outputs to a table which can then be imported into the test program. It turns out to be an efficient way to adjust many limits (especially with a GUI option to plot only the top N yield offenders).  We have other scripts to set limits via desired cpk or whatever math, but sometimes there's just too many distributions that are not ideal and this works quite well.

Here's an example of the output, in this case only one parameter was plotted, and I didn't group it.  The radio buttons would scale the axis, and the button box at the bottom would retrieve all of the min / max values and generate the table.

Because this script is used for a few different things, I'm sort of reluctant to completely rewrite it.  But I will see if I can make use of that column switcher in some manner or other in the near future.

8797_pastedImage_1.png

Thanks,

Mike

Re: HTML-like references within a JSL scripted display window

Mike,

The earlier TabBox() example should save as you want in PDF, but that doesn't offer the long report you are looking for.  So here is another option for you.  See the embedded comments for details.

Wendy


dt = Open( "$SAMPLE_DATA\Fitness.jmp" );


colList = dt << Get Column Names( Continuous, String );



/* New Window with a Summary OutlineBox and a separate Analyses OutlineBox */


nw = New Window( "Example 2", ob = Outline Box( "Summary" ), Outline Box( "Analyses", vl = V List Box() ) );


/* Initialize a list for storing references to the Distributions */


dist = {};



/* Loop through each column


     - append each Distribution to the Analyses Outline Box


     - append a button link to expand the specified Distribution OutlineBox */


For( i = 1, i <= N Items( colList ), i++,


       vl << Append( dist = Distribution( Continuous Distribution( Column( Column( colList ) ), Horizontal Layout( 1 ), Vertical( 0 ) ) ) );


       var = colList || " Distribution";


       Report( dist )[Outline Box( 1 )] << Set Title( var );


       Eval(


              Eval Expr(


                     ob << Append(


                           bb = Button Box( var,


                                  Current Window()[Expr( var )] << Close All Like This;


                                  Current Window()[Expr( var )] << Set Open( 1 );


                           )


                     )


              )


       );


       bb << UnderlineStyle( 1 );


);



/* Add a button to open all the OutlineBoxes and save the output as PDF */


ob << Append(


       Button Box( "Save All to PDF",


              Current Window()["Analyses"] << Open All Below;


              Current Window() << Set Page Setup( Scale(.75));


              path = Pick File( "Select PDF File", "E:\Trash", {"PDF|pdf"}, 1, 1, "Example 2.pdf" );


              Current Window() << SavePDF( path );


              Open( path );


       )


);



Wendy
mikedriscoll
Level VI

Re: HTML-like references within a JSL scripted display window

Thanks Wendy. I will review with some other users and see if this is ok. For a hundreds of parameters it will still be a bit of scrolling but shouldn't be too bad.

-Mike

mikedriscoll
Level VI

Re: HTML-like references within a JSL scripted display window

I was browsing the jmp scripting index today and saw the 'scroll box()' display box feature and it got me thinking that I can use that as a pseudo hyperlink. I just needed something 'clickable' that would take action when clicked.  I already had a summary table box() at the top of my report, so all I needed to do was make the rows of the table box selectable, and the combination of << set selectable rows() and << set row change function() does just that. When the selection changes, the function runs, the code determines which row is selected and as long as the plot order corresponds to the table order, we just scroll to the reference of the i'th context box (or whatever display box). I tried scrolling to 'db[i]' where db[i] = distribution(param[i],.......) but that didn't work, but proper display boxes did.

 

Some of this code is straight our of the scripting index, particularly the << set row change function(). The 'this' variable had me confused but all that is is the table box itself, which appears to be passed to the function when the row selection changes. For example, if you try to append 'this' to vlb it will just put another table box() at the bottom of vlb. 

 

One thing that is not handled well is if multiple rows are selected with a ctrl+click (cmd click on Mac), but I don't think this is a big deal. Other methods could be used... anything like a button box or << on change() could be used to scroll to the target. A list box, for example. 

 

This may have already been posted but I figured it was worth sharing.  Only took me 7 years to figure it out. Hope you find it useful.

 

 

Names Default To Here( 1 );

//dummy data table
dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

// get col list
colList = {};
for( i = 1, i<=20, i++,
	colList[i] = as column(dt, 4 + i) << get name();
);

// new window, table box with selectable rows
nw = New Window( "Example",
	vlb = vlistbox(
		Outline Box( "Table",
			tb = Table Box(
				String Col Box( "names", colList ),
				<<set selectable rows()
			)
		)
	);
);

vlb << append(lb = list box(colList));
lb<<get properties();
//append some distributions in their own context boxes, but keep a reference variable for the conext box cb[i].

cb = {};
for( i = 1, i <= 20, i++,
	vlb <<  append(
		cb[i] = contextbox(
			distribution(column(4 + i))
		)
	);
);

//set what happens when a row is selected. itemNum is a matrix of all selected rows. I don't think there's a way to limit max rows = 1, so control clicking will return multiple rows, and we'll just use the first.
tb << set row change function(
	Function( {this},
		Print( this << get selected rows );
		itemNum = this << get selected rows();
		if(nrows(itemNum) > 0,
			nw << scroll window(cb[itemNum[1]]);
		);
	)
);