I'm currently working on a small genealogy experiment and would like to implement a simple family tree like in the picture below.
The best search results so far for this only yielded examples where a child can only have a parent node. But what I need is the ability to create links between entities (from father to mother) and links between nodes and other links (from child to the father-mother link). Currently I don't have a fixed data schema for this.
I've chosen d3.js for this because it looks like would be capable of doing the job. I just don't know how or even where to start. Tutorials about d3.js only cover standard charts like bar charts.
I hope someone can help me with this.
dTree is an open source library built on-top of D3 that creates family trees (or similar hierarchical graphs).
It handles the bothersome parts of generating the D3 graph manually and uses a simple json data format:
If you are interested in modifying it supports callback for node rendering and event handler. Finally the library is as of 2016 under development and pull requests are welcomed.
DISCLAIMER: I'm the author of dTree. I created the library after searching the web just like you did and not finding anything to my liking.
I don't know if this is of any help to you, because you said that you were going to use d3.js but there is another tool that you might want to look into using called jsplumb. It seems perfect for this kind of project: home page. They also have some decent tutorials. There is one more like docs, and another more interactive.
Like I said, if it's not too late to switch technologies, this might be worth trying. It's all html, css, and javascript, so it shouldn't be a harsh transition.
I know this question is rather old, but if anyone still interested, please have a look at my sample here.
Answering 3 years after the question.
There is now a Pedigree Tree graph from Mike
https://bl.ocks.org/mell0kat/5cb91a2048384560dfa8f041fd9a0295
Then there is this d3.tree - A Family Tree https://bl.ocks.org/mell0kat/5cb91a2048384560dfa8f041fd9a0295
You can also try the D3 Tidy Tree again from Mike https://beta.observablehq.com/@mbostock/d3-tidy-tree
My approach is as under:
Lets take the example you have illustrated in the attached figure:
Jenny Of Oldstones is also a the child of Aegon V but the difference between this child and other children of Aegon V is that in this case I am not drawing the link between it.
This is done by setting the node as no_parent: true in the node JSON example:
In the code check the
_elbow
function_ this does the job of not drawing the line between it and its parent:Next scenario is the link going between Node Aerys II and Rahella this node has its set of children.
hidden: true,
display:none
for such node. It appears that the children are coming from the line between node Aerys II and RahellaJSON Example:
In the code check the place where I make the rectangles, the code below hides the node:
Full code is in here: http://jsfiddle.net/cyril123/0vbtvoon/22/
In the example above, I have made the use of node names A/B/C... but you can change it as per you requirements. You will need to center the text.
I have added comments to the code to help you understand the flow. Just in case you are not clear on any point please comment I ll be happy to clarify.
The not-as-good news: The research I have done shows that there is no out-of-the-box d3 library that directly accomplishes this without some customization.
The good news: There have been some other people who have looked into this and have found some great starting points! I realize that this is not a complete solution to the entire task at hand, but it seems from your question that a large portion of your difficulty so far has been simply figuring out where to start (e.g. "Tutorials about d3.js only cover standard charts like bar charts."). In the absence of anything better, I will at least respond to that portion here.
First, in the response to this related stackoverflow post from a few years back, inanutshellus provides some great d3 tools that are available and could be of use here. With some light customization/extension, they should be able to get you where you're going relatively quickly. For posterity, inanutshellus's answer is reproduced here:
In terms of concrete implementation, mj8591 asked this question regarding a similar family tree with a different problem. However, luckily for you that question includes a fiddle (all the js code) that has most or all the components that you need, and the response from mdml includes another fiddle that adds some more granular "clickability" to each node.
Again, it's nothing automagic but hopefully these resources are enough to get you a great start!