I am a noob in web-development. I'm trying to create a tree-like hierarchical company org chart. I tried both google's visualization chart and Mike Bostock's D3 Reingold tree.
I want these features :
- tree structure : either top-down (google) or left-right (D3)
- online/dynamic : viewable in browser and able to read data from json (both google & D3), not static visio or ppt diagram
- collapsible : able to hide subtrees (both)
- space-adjusting : nodes should fill visible area, to reduce scrolling (only D3)
- attributes : display name, title & possibly picture (only google)
Above I've marked which tool allows which features, afaik.
I prefer the D3 version because it looks cool.
I can modify the .json to include additional fields (title, url to photo etc.) - here is a sample
My question is - how do I modify the D3 code to display an employee's name, then title in the next line, and maybe picture too ?
Or if that's not feasible - how do I modify the google code to automatically adjust spacing, so that all children of a node are close together, and I don't have to horizontally scroll ?
If you like to create your project with D3js, Just need to use the
script
codes from this and replaced3.json("/mbostock/raw/4063550/flare.json", function(error, flare)
with this :The
jsonFileName.json
is your customized json file like this sample. Also you can insert name of your pictures into the json file and replace theimg
tag src with it.Here's a quick example. It modifies this example, to add in first name, last name, a title and a picture.
Reversed Direction: