/
Showing a tree of data

Showing a tree of data

Start with one node:

var TREEdata={ children : [], label : "Vismay's Concept's" }

 

function TREEaddChildren(N){ for (var i=0; i < N; i++){ TREEdata.children[i] = { label : "Node " + i, children : []} } }

 

 

function TREErender(T){ var H = ''; H += "<div class='TREEnode'>" + T.label; for (var i=0; i < T.children.length; i++){ H+= TREErender(T.children[i]); } H += "</div>"; return H; }

We add a bit of styling:

We put a containing div around it.

We contain the tree with this:

 

 

 

 

 

 

 

Related content

Javascript Variables - Covering the core types
Javascript Variables - Covering the core types
Read with this
Do not store application data in the DOM
Do not store application data in the DOM
More like this
How can we extract data from Confluence?
How can we extract data from Confluence?
Read with this
Dealing with loops with create Closures
Dealing with loops with create Closures
More like this
How do I find the element my virtual cursor should be in?
How do I find the element my virtual cursor should be in?
More like this
How do we make a Javascript sandbox
How do we make a Javascript sandbox
More like this