Page 1 of 1
Representing a tree in HTML
Posted: Fri Jun 06, 2003 8:52 am
by Gleeb
I thought this should be put under advanced because it's a theory question more than a practical, and iirc, that's the purpose of this part fo the forum.
How would you represent a tree in HTML? I've got a basic system working, but it doesn't look very tree-like, because it's in a table...
Any thoughts?
Posted: Fri Jun 06, 2003 8:54 am
by twigletmac
I've moved this to Client Side because as far as I could see it isn't to do with PHP.
Mac
Posted: Fri Jun 06, 2003 9:36 am
by Gleeb
good call

Any takers?
Posted: Fri Jun 06, 2003 10:06 am
by nielsene
What do you need to represent and why HTML? For example would it make sense to play with creating an image on the fly using some of the image manipulation commands?
Posted: Fri Jun 06, 2003 10:18 am
by Gleeb
Well, basically, I can't use any images other that the ones provided for me, because the site will be viewed over modems. It has to be low bandwidth, and that means HTML, apparently.
Posted: Fri Jun 06, 2003 10:21 am
by nielsene
ASCII art in a <pre>? Is it a binary tree or a generalized tree?
Posted: Fri Jun 06, 2003 10:24 am
by volka
www.hotscripts.com has some scripts,
phpclasses.org too
...and many more

what kind of tree do you want to display?
Posted: Mon Jun 09, 2003 6:39 am
by Gleeb
I suck at being specific
Okay, I need to generate a tree. Each node can have multiple children nodes. Each and Every Node has other peices of information that must be displayed... how would you do it?
(Example node)
(NodeID = 53)
(ParentNode = 24)
(Info1 = 'Some Info')
(Info2 = 'Some Info')
(Info3 = 'Some Info')
(Info4 = 'Some Info')
(Info5 = 'Some Info')
Posted: Sun Jun 22, 2003 1:41 pm
by 9902468
Im not completely sure if I understood your problem correctly, but here it goes.
1.
If you have lots and lots of data, be sure to give enough narrowing parameters to users
2.
Display only as much data in each node as you see that is the absolute minimum. Remember that every node must be still somehow indentifiable.
3.
Give user some method to examine that node closer: it can be done in many ways. (Node can open popup, it can display the data after user has kept cursor in the node long enough, there can be frames and one frame is updated when user clicks a node etc.
As coding side of things, (I recently did something like that with java servlets, it used tables and it works pretty well.) it shouldn't be too hard:
- load all appropriate data from db
- sort the data in multidimensional array
- calculate how much of the sorted data is actually visible, depending what user has clicked (only if it is a folding one.) ditch what you dont need
- calculate how many cols does it take to show the data (widest part of the tree)
- calculate how many rows does it take to show the data (how tall the tree is)
- construct the table
and thats it. The sorting part was the thoughest for me, as my app could have n number of roots, and those roots can all open to x number of nodes that opens to y number, well, you get the idea. It was also a folding one.
Hope this helps,
-99