TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Design question on rendering graphics (http://www.talkphp.com/general/6054-design-question-rendering-graphics.html)

mfouwaaz 12-04-2011 06:45 PM

Design question on rendering graphics
 
Hello php gurus

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:

CATEGORY_ID
CATEGORY_NAME
PARENT_ID

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.

Thanks :-)


All times are GMT. The time now is 09:11 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0