Choose Language Hide Translation Bar
Highlighted
tom_abramov
Level V

hierarchical display box

Hi,

What is the best way to create the hierarchical group of boxes with JSL?

For example, I want to create a distribution for every gender and every age (Big Class.jmp) and then I want to arrange them like in file explorer.

(Please see attached a screenshot)

I hope my question is clear

 

Thank you

Tom.

Screen Shot 02-09-20 at 08.36 AM.PNG

 
 
 
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: hierarchical display box

This example illustrates one approach:

 

Names Default to Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

window = New Window( "Hierarch", vlb = V List Box() );

Summarize( sex group = By( :sex ) );
Summarize( age group = By( :age ) );

For( sex = 1, sex <= N Items( sex group ), sex++,
	outline = Outline Box( "Sex = " || sex group[sex] );
	For( age = 1, age <= N Items( age group), age++,
		outline << Append(
			Outline Box( "Age = " || age group[age],
				Text Box( "Sex is " || sex group[sex] || " and Age is " || age group[age] )
			)
		);
		Show( sex, age );
	);
	vlb << Append( outline );
);
Learn it once, use it forever!

View solution in original post

6 REPLIES 6
Highlighted

Re: hierarchical display box

This example illustrates one approach:

 

Names Default to Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

window = New Window( "Hierarch", vlb = V List Box() );

Summarize( sex group = By( :sex ) );
Summarize( age group = By( :age ) );

For( sex = 1, sex <= N Items( sex group ), sex++,
	outline = Outline Box( "Sex = " || sex group[sex] );
	For( age = 1, age <= N Items( age group), age++,
		outline << Append(
			Outline Box( "Age = " || age group[age],
				Text Box( "Sex is " || sex group[sex] || " and Age is " || age group[age] )
			)
		);
		Show( sex, age );
	);
	vlb << Append( outline );
);
Learn it once, use it forever!

View solution in original post

Highlighted
pmroz
Super User

Re: hierarchical display box

 

After I posted this response I tried the code again and it worked no problem!  Sorry Mark!

 

Mark I had to change your looping variables because they're the same as column names in Big Class.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

window = New Window( "Hierarch", vlb = V List Box() );

Summarize( sex group = By( :sex ) );
Summarize( age group = By( :age ) );

For( isex = 1, isex <= N Items( sex group ), isex++,
	outline = Outline Box( "Sex = " || sex group[isex] );
	For( iage = 1, iage <= N Items( age group), iage++,
		outline << Append(
			Outline Box( "Age = " || age group[iage],
				Text Box( "Sex is " || sex group[isex] || " and Age is " || age group[iage] )
			)
		);
		Show( isex, iage );
	);
	vlb << Append( outline );
);

 

Highlighted
pmroz
Super User

Re: hierarchical display box

A tree box containing tree nodes might be closer to what you want.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Summarize( sex group = By( :sex ) );
Summarize( age group = By( :age ) );
gender_tree = {};
For( isex = 1, isex <= N Items( sex group ), isex++,
	gnode = tree node( "Gender - " || sex group[isex] );
	For( iage = 1, iage <= N Items( age group), iage++,
		age_node = tree node(age group[iage]);
		gnode << append(age_node);
	);
	insert into(gender_tree, gnode);
);

nw = New Window( "Hierarchy Tree", 
	gtree = tree box(gender_tree, size(300, 300),
		set max size(600, 600),
		set autostretching(1, 1)
	)
);

root_list = gtree << get roots;
for (i = 1, i <= nitems(root_list), i++,
	gtree << expand(root_list[i]);
);

Gender Treebox.png

Highlighted
Craige_Hales
Staff (Retired)

Re: hierarchical display box

There is also a hierarchy box, mostly for Ishikawa Fishbone diagrams, but with 3 presentation styles.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

window = New Window( "Hierarch", vlb = Hier Box( Text Box( "Big Class" ) ) );

Summarize( sex group = By( :sex ) );
Summarize( age group = By( :age ) );

For( isex = 1, isex <= N Items( sex group ), isex++,
	outline = Hier Box( Text Box( "Sex = " || sex group[isex] ) );
	For( iage = 1, iage <= N Items( age group ), iage++,
		Eval(
			Eval Expr(
				outline << Append(
					Hier Box(
						Text Box( "Age = " || age group[iage] ),
						Button Box( "Sex is " || sex group[isex] || " and Age is " || age group[iage],
							// the button runs a script, use eval(evalexpr(...expr(xxx)))
							// to capture a value of a variable that was only available 
							// while the display box tree was being constructed...
							Print( Expr( age group[iage] ), Expr( sex group[isex] ) )
						)
					)
				)
			)
		);
		
	);
	vlb << Append( outline );
);
vlb << changetype( "fishbone" );
Wait( 1 );
vlb << changetype( "hierarchy" );
Wait( 1 );
vlb << changetype( "nested" );

three styles of hier box presentationthree styles of hier box presentation

I substituted button box for the text box. Clicking one of them says:

"13"
"F"

 

Craige
Highlighted
txnelson
Super User

Re: hierarchical display box

Craige,

Cool......

Jim
Highlighted
tom_abramov
Level V

Re: hierarchical display box

What is the best way to do this with Tab boxes?

@markbailey 

Thanks!

Article Labels

    There are no labels assigned to this post.