I want to generate this:
With this data structure (ids are random, btw not sequential):
var tree = [
{ \"id\": 1, \"name\": \"Me\", \"dob\":
This is not trivial question and it involves large corpus of research in graph drawing algorithms.
The most prominent approach for this problem is through constraints satisfaction. But don't try to implement this on your own (unless you want to learn something new and spend months debugging)
I cannot recommend highly enough this library: cola.js (GitHub)
The particular example that may be very close to what you need is grid layout.