I am brand new to your forum and would like to have your expert opinions on this. I have a hierarchichal tree mapped on a database as follows:
Some categories have PARENT_IDs and some have not. Those who have are 'children' of the PARENT_ID given. A single parent can have many children.
Now, I need to show this graphically as boxes with the category names inside them as follows:
The top categories -- those without parents will be shown as separate boxes at the top in a row. Then below each will be shown their children and then the children of each child and so on until the contents of the database table are exhausted. It will be like a christmas tree (or trees) with a box at the top branching off other boxes at lower levels.
Do you know the best way to do this?
I was intially thinking of starting off drawing the top level boxes (GD imagefilledrectangle) and then building downwards recursively. But since I would run into negative X coordinates as the tree grows wider downward, I thought of capturing all the data into an array first (coordinates and all, including negatives) and identifying the left-most coordinate (least -X) and then using that as 0 and offsetting the rest of the x coordinates by the same amount to do the actual build. It is a bit complicated but I guess it could work.
I want to store the image in the file system once it is created until there is a change in the table so it should be built as an image file. Hence, I need to also 'glue' the boxes together to form a composite picture. Lastly I have to build a image map (with hotspots) so that a particular box (category) can be selected for further action. I haven't done a complete proof of concept yet.
Now, I saw this pixel by pixel stuff and it looks kind of promising as well, but I have never worked with it. I will be very happy to hear your views of this and / or suggestions of the whole thing or parts of it or alternative ways of doing this.