cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
DMR
DMR
Level V

Applying the broadcasting command to a set of Outline Boxes

Hi - I have a JSL script that sends a number of Outline Boxes to the journal from within a for loop (i.e. each cycle of the loop creates a new Outline Box, of which I send a copy to the journal as soon as it is created). Is there a way I can make the resulting set of Outline Boxes within the journal open or close in unison by using the broadcasting key combination (i.e. holding down the <Ctrl> key while opening or closing just one of them)?

 

I've written a number of applications in which I want to be able to do this. In some of them I seem to have inadvertantly incorporated this functionality anyway, whereas in others I haven't - but I can't work out where the difference lies in the way that I've scripted them. In all instances, the Outline Boxes contain an identically-formatted data summary in which the only difference lies in the actual numbers being summarized.

 

Many thanks for any suggestions.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Applying the broadcasting command to a set of Outline Boxes

Unfortunately, it is not possible for you to change the helpKey values, as they are relied on by JMP.

However, you could create a button that expaned/collapses all of the OutlineBoxes instead of using the control key, relying on OutlineBox titles and helpKeys. See my example below for details

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Owl Diet.jmp" );

yList = dt << get column names( string );

Remove From( yList, N Items( yList ) );

nw = New Window( "Example",
	Button Box( "Collapse All",
		<<Set Function(
			Function( {this},
				{Default Local},
				// this << sib refers to the variable 'vlb' but I used this sibling relationship to 
				// ensure it works even if you move it to a journal
				// This Xpath command will grab all OutlineBoxes that are children of the V List Box
				// Using an xpath query of "//OutlineBox" would be simpler, but would cause child
				// OutlineBoxes of the Distribution to also be collapsed. This method ensures we only 
				// get the top level OutlineBoxes
				topLevelOutlineBoxes = (this << sib) << XPath( "/ListBox/OutlineBox" );
				// Account for Graph Builder case where there is an extra level between the ListBox
				// and the OutlineBox
				Insert INto( topLevelOutlineBoxes, (this << sib) << XPath( "/ListBox/*/OutlineBox" ) );
				// If we want to collapse
				If( this << Get button name == "Collapse All", 
					// close all of the top level OutlineBoxes
					topLevelOutlineBoxes << Set Open( 0 );
					// Change the button name
					this << set button name( "Expand All" );
				,
					// open all of the top level OutlineBoxes
					topLevelOutlineBoxes << Set Open( 1 );
					// Change the button name
					this << set button name( "Collapse All" );
				);
			)
		)
	),
	vlb = V List Box()
);

// append a graph builder and a distribution for each Y variable to the V LIst Box
For( i = 1, i <= N Items( yList ), i++,
	vlb << Append(
		dt << Graph Builder(
			Show Control Panel( 0 ),
			Show Legend( 0 ),
			Variables( X( :species ), Y( As Column( Column( dt, yList[i] ) ) ) ),
			Elements( Box Plot( X, Y, Legend( 6 ) ) ),
			SendToReport(
				Dispatch(
					{},
					"Graph Builder",
					OutlineBox,
					{Set Title( "Analysis of " || Titlecase( yList[i] ) )}
				),
				Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
				Dispatch( {}, "400", LegendBox, {Set Title( "" )} )
			)
		)
			
	);
	vlb << Append(
		dt << Distribution(
			Stack( 1 ),
			Continuous Distribution(
				Column( :skull length ),
				Horizontal Layout( 1 ),
				Vertical( 0 )
			)
		)
	);
);

// if you really want a journal
nw << Journal();
nw << Close Window();

ExpandedExpanded

CollapsedCollapsed

Justin

View solution in original post

5 REPLIES 5
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Applying the broadcasting command to a set of Outline Boxes

From my experience if you make the outline box titles match then they all open or all close with the control key (on windows).  Right clicking on one and hovering over 'Close all like this' brings up a tool tip that indicates that identical help keys has the same effect but I have not found references to using help keys in journals or JSL.

 

mass open.PNG

DMR
DMR
Level V

Re: Applying the broadcasting command to a set of Outline Boxes

Hi - thanks for this, and I've verified that indeed if the outline boxes all have the same title, I can then open and close them simultaneously with a broadcasted open/close command. Unfortunately I do actually need them to have different titles, since once they're all closed, I can't easily tell which one(s) I specifically want to open.

 

I've found an example of one of my scripts working the way I want - but it relates to a situation in which I'm sending multiple copies of the Graph Builder output to the journal from within a for loop. With each run of the loop, I change the variables that the Graph Builder is plotting, and I then send a copy to the journal before running the next one. The relevant part of the script works like this:

 

 

  dt = Open( "$SAMPLE_DATA/Owl Diet.JMP" );

yList = dt << get column names(string);
remove from(yList, nItems(yList));

show(yList);

// Create the chart as I want it to look for the first item on the list, and send a copy of it to the journal;

gb = Graph Builder(
	Show Control Panel( 0 ),
	Size( 600, 250 ),
	Show Legend( 0 ),	
	Variables( X( :species ), Y( as column(column(dt, yList[1])) ) ),
	Elements( Box Plot( X, Y, Legend( 6 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			OutlineBox,
			{Set Title( "Analysis of " || title case(yList[1]) )}
		),
		Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
		Dispatch( {}, "400", LegendBox, {Set Title( "" )} )
	)
);

report(gb) << journal();

// Then run all the others in sequence by each time replacing the current Y variable with the next one, and adding them to the journal as we go;

for(i=2, i<=nItems(yList), i++,

	gbb = report(gb);
	
	gbb << Dispatch( {}, "Graph Builder",   OutlineBox,  {Set Title( "Analysis of " || title case(yList[i]) )} );

	gbb[GraphBuilderBox(1)] << remove variable(2);
	gbb[GraphBuilderBox(1)] << add variable({as column(column(dt, yList[i])), role("Y")});
	
	gbb << journal()
	
);
	
// Finally, close the original chart window;

gb << close window;

 

 

 

The broadcasting command works in this instance, presumably because all the charts are actually called "Graph Builder" despite all having been given different labels - and it's this effect that I want to reproduce when I'm sending outline boxes to the journal that weren't created using the Graph Builder.

 

Any suggestions are welcome, though I may be asking the impossible.

Many thanks.

 

ih
Super User (Alumni) ih
Super User (Alumni)

Re: Applying the broadcasting command to a set of Outline Boxes

This must be due to the common HelpKey shared by all of the graph builder outputs. The best reference I found to HelpKeys was here, maybe @Justin_Chilton can shed some light on whether the HelpKey can be set when sending something to a Journal, or modified for an item in the Journal? If that is not possible a workaround would be to insert a text item between each output:

 

byspecies.PNG

If you move the graph builder output under an outline box you can see the HelpKey using 'show tree structure':

HelpKey.png

 

 

Re: Applying the broadcasting command to a set of Outline Boxes

Unfortunately, it is not possible for you to change the helpKey values, as they are relied on by JMP.

However, you could create a button that expaned/collapses all of the OutlineBoxes instead of using the control key, relying on OutlineBox titles and helpKeys. See my example below for details

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Owl Diet.jmp" );

yList = dt << get column names( string );

Remove From( yList, N Items( yList ) );

nw = New Window( "Example",
	Button Box( "Collapse All",
		<<Set Function(
			Function( {this},
				{Default Local},
				// this << sib refers to the variable 'vlb' but I used this sibling relationship to 
				// ensure it works even if you move it to a journal
				// This Xpath command will grab all OutlineBoxes that are children of the V List Box
				// Using an xpath query of "//OutlineBox" would be simpler, but would cause child
				// OutlineBoxes of the Distribution to also be collapsed. This method ensures we only 
				// get the top level OutlineBoxes
				topLevelOutlineBoxes = (this << sib) << XPath( "/ListBox/OutlineBox" );
				// Account for Graph Builder case where there is an extra level between the ListBox
				// and the OutlineBox
				Insert INto( topLevelOutlineBoxes, (this << sib) << XPath( "/ListBox/*/OutlineBox" ) );
				// If we want to collapse
				If( this << Get button name == "Collapse All", 
					// close all of the top level OutlineBoxes
					topLevelOutlineBoxes << Set Open( 0 );
					// Change the button name
					this << set button name( "Expand All" );
				,
					// open all of the top level OutlineBoxes
					topLevelOutlineBoxes << Set Open( 1 );
					// Change the button name
					this << set button name( "Collapse All" );
				);
			)
		)
	),
	vlb = V List Box()
);

// append a graph builder and a distribution for each Y variable to the V LIst Box
For( i = 1, i <= N Items( yList ), i++,
	vlb << Append(
		dt << Graph Builder(
			Show Control Panel( 0 ),
			Show Legend( 0 ),
			Variables( X( :species ), Y( As Column( Column( dt, yList[i] ) ) ) ),
			Elements( Box Plot( X, Y, Legend( 6 ) ) ),
			SendToReport(
				Dispatch(
					{},
					"Graph Builder",
					OutlineBox,
					{Set Title( "Analysis of " || Titlecase( yList[i] ) )}
				),
				Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
				Dispatch( {}, "400", LegendBox, {Set Title( "" )} )
			)
		)
			
	);
	vlb << Append(
		dt << Distribution(
			Stack( 1 ),
			Continuous Distribution(
				Column( :skull length ),
				Horizontal Layout( 1 ),
				Vertical( 0 )
			)
		)
	);
);

// if you really want a journal
nw << Journal();
nw << Close Window();

ExpandedExpanded

CollapsedCollapsed

Justin
DMR
DMR
Level V

Re: Applying the broadcasting command to a set of Outline Boxes

Many thanks for both suggestions - I'll use one of the suggested workarounds, both of which will do the job just as well.  As always, it's useful to know that there isn't a trivial trick that I just missed :)