d3.tree - A Family Tree
This example visualizes a family tree as a static hierarchical diagram, showing genealogical relationships with names, birth and death years, and locations. The graph uses the d3.tree layout to position nodes, while d3.hierarchy structures the JSON data and provides descendant and link methods. Links are drawn as elbow paths with a custom function, and each node displays three text elements for the relative information. The visualization is rendered in SVG with a clean, readable design, demonstrating how d3.v4 handles tree layouts and nested data.
AI-generated descriptionBuilt with blockbuilder.org
d3.tree - A Family Tree
This graph is based on Mike Bostock's block converted to d3 v4
What I've learnt
d3.hierarchy() constructs a root node from given hierarchal (json) data
nodes have .descendants() method as well as .links() which have a source and target object
d3.tree() assigns a .x and .y (which are arbitrary, could be used for angle and radius) to the root node and its decendants
for svg elements, x and y are absolute coords while dx and dy are relative coords
dx and dy use 'em's are are good for centering things
can add multiple classes be simply space separating
- e.g .attr('class', 'about location')
forked from <a href='http://bl.ocks.org/mell0kat/'>mell0kat</a>'s block: <a href='http://bl.ocks.org/mell0kat/5cb91a2048384560dfa8f041fd9a0295'>d3.tree - A Family Tree</a>