<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dynamic JSL Tree Box Creation from Hierarchical Data in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469309#M71308</link>
    <description>&lt;P&gt;I think that this fits your needs as I understand them:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );
dt = Data Table( "DummyTable" );
relations = [=&amp;gt;];
For Each Row( dt,
	relations[:FULL_NAME] = Tree Node( :FULL_NAME );
	relations[:FULL_NAME] &amp;lt;&amp;lt;Set Data( Eval List( {:FULL_NAME, :EMP_ID, :MANAGER_NAME, :MGR_ID, :EMPLEVEL} ) );
);
roots = {};
For Each Row( dt,
	If( :MANAGER_NAME != "" &amp;amp; relations &amp;lt;&amp;lt; Contains( :MANAGER_NAME ),
		relations[:MANAGER_NAME] &amp;lt;&amp;lt; Append( relations[:FULL_NAME] )
	,
		roots[N Items( roots ) + 1] = relations[:FULL_NAME]
	);
);

New Window( "TreeBox Tests", tree = Tree Box( roots, Size( 300, 500 ) ) );

key = relations &amp;lt;&amp;lt; First;
While( !Is Empty( key ),
	Try( tree &amp;lt;&amp;lt; Expand( relations[key] ) );
	key = relations &amp;lt;&amp;lt; Next( key )
);
tree &amp;lt;&amp;lt; Set Node Select Script(
	Function( {this, node},
		Print( node &amp;lt;&amp;lt; Get Data )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 12 Mar 2022 10:40:34 GMT</pubDate>
    <dc:creator>ErraticAttack</dc:creator>
    <dc:date>2022-03-12T10:40:34Z</dc:date>
    <item>
      <title>Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469248#M71301</link>
      <description>&lt;P&gt;Can someone suggest a method of creating a dynamic nested tree box using&amp;nbsp;Hierarchical Data. I tried for a couple of hours tonight and it is confounding me :(&lt;/img&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some dummy data below to depict the relationships which is three levels deep. Obviously I don't want to hard code this as I will not know up front how many level of 'nesting' I will need to make. In reality it will be 10 or more levels.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers, Troy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I'm starting with (Table attached)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thickey_0-1647045806081.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40756i3530242E4D9DB090/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thickey_0-1647045806081.png" alt="thickey_0-1647045806081.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I want to generate&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thickey_1-1647046228587.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40757i57D0F2104A278B82/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thickey_1-1647046228587.png" alt="thickey_1-1647046228587.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:12:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469248#M71301</guid>
      <dc:creator>thickey</dc:creator>
      <dc:date>2023-06-09T18:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469299#M71305</link>
      <description>&lt;P&gt;Here is something I put together using your sample table, that might help you get to where you want&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1647063592382.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40765i6364B772600FD66C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1647063592382.png" alt="txnelson_0-1647063592382.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
maxLevels = Col Max( :EMPLEVEL );
dt &amp;lt;&amp;lt; select where( :EMPLEVEL == 1 );
dtJoined = dt &amp;lt;&amp;lt; subset( columns( :EMP_ID, :FULL_NAME ), selected rows( 1 ) );
For( m = 1, m &amp;lt;= N Cols( dtJoined ), m++,
	Column( dtJoined, m ) &amp;lt;&amp;lt; set name( Column( dtJoined, m ) &amp;lt;&amp;lt; get name || "1" )
);
For( i = 2, i &amp;lt;= maxLevels, i++,
	dt &amp;lt;&amp;lt; select where( :EMPLEVEL == i );
	dtTemp = dt &amp;lt;&amp;lt; subset( columns( :EMP_ID, :FULL_NAME, :MGR_ID ), selected rows( 1 ) );
	For( m = 1, m &amp;lt;= N Cols( dtTemp ), m++,
		Column( dtTemp, m ) &amp;lt;&amp;lt; set name( Column( dtTemp, m ) &amp;lt;&amp;lt; get name || Char( i ) )
	);
	Eval(
		Substitute(
				Expr(
					dtTemp2 = dtJoined &amp;lt;&amp;lt; Join(
						With( dtTemp ),
						Merge Same Name Columns,
						Match Flag( 0 ),
						By Matching Columns( __emp__ = __mgr__ ),
						Drop multiples( 0, 0 ),
						Include Nonmatches( 0, 0 ),
						Preserve main table order( 1 )
					)
				),
			Expr( __emp__ ), parse(":EMP_ID" || Char( i - 1 )),
			Expr( __mgr__ ), Parse(":MGR_ID" || Char( i ))
		)
	);
	Close( dtTemp, nosave );
	Close( dtJoined, nosave );
	dtJoined = dtTemp2;
);

theNameList={};
for(i=1,i&amp;lt;=maxLevels,i++,
	insert into(theNameList, parse(":FULL_NAME" || char(i)))
);

Tabulate(
	Show Control Panel( 0 ),
	Add Table(
		Row Table( Grouping Columns( eval(theNameList) ) )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Mar 2022 05:40:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469299#M71305</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-12T05:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469304#M71306</link>
      <description>&lt;P&gt;You might get some ideas from here &lt;LI-MESSAGE title="Directory Tree: Explore Space Used by Folders" uid="456571" url="https://community.jmp.com/t5/Uncharted/Directory-Tree-Explore-Space-Used-by-Folders/m-p/456571#U456571" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt; or possibly from file-indexer I have been working on&amp;nbsp;&lt;A href="https://github.com/jthi-jmp-tools/file-indexer" target="_blank" rel="noopener"&gt;jthi-jmp-tools/file-indexer (github.com)&lt;/A&gt; (see bin/bin/DirectoryTreeHandler.jsl, it isn't yet as generic as I would like it to be, but hopefully it will get there), my code is currently a mess, because I haven't had time to finish it and start refactoring.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my code the (current) input is datatable like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1647070753550.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40766i3B2E9C55EBD05A73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1647070753550.png" alt="jthi_0-1647070753550.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and current end result something like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1647070788434.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40767i0AD528BAB8DF30BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1647070788434.png" alt="jthi_1-1647070788434.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I modified the input directory list to include one much deeper directory and it seemed to have no issues. I think magic word here might be recursion&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_2-1647071008582.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40768i8ADD42D3C61C4BFD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_2-1647071008582.png" alt="jthi_2-1647071008582.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hopefully the function get_directory_roots can give you some ideas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;&lt;LI-MESSAGE title="JSL Function List" uid="67439" url="https://community.jmp.com/t5/JMP-Add-Ins/JSL-Function-List/m-p/67439#U67439" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt; addin can also provide some ideas, I think it didn't have more than 1 or two levels&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 07:50:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469304#M71306</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-12T07:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469309#M71308</link>
      <description>&lt;P&gt;I think that this fits your needs as I understand them:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );
dt = Data Table( "DummyTable" );
relations = [=&amp;gt;];
For Each Row( dt,
	relations[:FULL_NAME] = Tree Node( :FULL_NAME );
	relations[:FULL_NAME] &amp;lt;&amp;lt;Set Data( Eval List( {:FULL_NAME, :EMP_ID, :MANAGER_NAME, :MGR_ID, :EMPLEVEL} ) );
);
roots = {};
For Each Row( dt,
	If( :MANAGER_NAME != "" &amp;amp; relations &amp;lt;&amp;lt; Contains( :MANAGER_NAME ),
		relations[:MANAGER_NAME] &amp;lt;&amp;lt; Append( relations[:FULL_NAME] )
	,
		roots[N Items( roots ) + 1] = relations[:FULL_NAME]
	);
);

New Window( "TreeBox Tests", tree = Tree Box( roots, Size( 300, 500 ) ) );

key = relations &amp;lt;&amp;lt; First;
While( !Is Empty( key ),
	Try( tree &amp;lt;&amp;lt; Expand( relations[key] ) );
	key = relations &amp;lt;&amp;lt; Next( key )
);
tree &amp;lt;&amp;lt; Set Node Select Script(
	Function( {this, node},
		Print( node &amp;lt;&amp;lt; Get Data )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Mar 2022 10:40:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469309#M71308</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-03-12T10:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469310#M71309</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26363"&gt;@ErraticAttack&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Great solution!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 10:49:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469310#M71309</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-12T10:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469335#M71313</link>
      <description>&lt;P&gt;The fishbone diagrams have a right-click menu to rearrange them. They all use the same displaybox tree. It is possible to add other controls to the tree, similar to the label. The platform is hiding under Analyze-&amp;gt;QualityAndProcess-&amp;gt;Diagram.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open("/Z:/DummyTable.csv");
diagram = dt &amp;lt;&amp;lt; diagram(parent(MGR_ID),child(EMP_ID),label(FULL_NAME));
// fishbone is the default, change it like this:
(report(diagram)[hierbox(1)])&amp;lt;&amp;lt;changetype(
    Fishbone
    //Hierarchy
    //Nested
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nested" style="width: 318px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40773iE37813D825EE1D4E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Nested.png" alt="Nested" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Nested&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Fishbone" style="width: 849px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40771iCFA80AEF370CC702/image-size/large?v=v2&amp;amp;px=999" role="button" title="Fishbone.png" alt="Fishbone" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Fishbone&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hierarchy" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40772i12430D1351C64DC5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Hierarchy.png" alt="Hierarchy" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Hierarchy&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: it looks like the diagram platform may not be able to reopen a closed node in JMP 15/16 (via popup menu). In JMP 14 it can. I've reported the issue.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 15:23:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469335#M71313</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-03-12T15:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469362#M71319</link>
      <description>&lt;P&gt;Yes, I agree. Very elegant solution. I was headed down the road of tracking parent/child relationships and things were starting to get messy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks all for the replies, many excellent snippets of code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Troy&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 23:48:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/469362#M71319</guid>
      <dc:creator>thickey</dc:creator>
      <dc:date>2022-03-12T23:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/478416#M72253</link>
      <description>&lt;P&gt;Thanks for reporting the issue with the inability to reopen a closed node,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;.&amp;nbsp;The bug has been addressed in JMP 17.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2022 17:57:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/478416#M72253</guid>
      <dc:creator>Audrey_Shull</dc:creator>
      <dc:date>2022-04-11T17:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic JSL Tree Box Creation from Hierarchical Data</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/663640#M85207</link>
      <description>&lt;P&gt;seems that the code got truncated&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 20:01:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-JSL-Tree-Box-Creation-from-Hierarchical-Data/m-p/663640#M85207</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2023-07-28T20:01:32Z</dc:date>
    </item>
  </channel>
</rss>

