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:
Â
Â
Â
Â
Â
Â
Â