'Build a d3 tree from a database
I want to draw a tree with d3 where each node is a person. In my database I have a table that correspond to a person and in another table I have the relationship between each persons.
I don't know how to create the data structure in js that is needed by d3 tree.
I retrieve data in json with this format :
{
"peoples": [
{
"id": 0,
"first_name": "Louis",
"last_name": "E",
"birthdate": "03-31-2000",
"promo": 4,
"description": "eczc"
},
{
"id": 1,
"first_name": "Max",
"last_name": "D",
"birthdate": "31-01-1999",
"promo": 5,
"description": "dzeczc"
},
{
"id": 2,
"first_name": "Thomas",
"last_name": "Z",
"birthdate": "03-04-2005",
"promo": 9,
"description": "edzfc"
}
],
"relationships": [
{
"id": 0,
"godfather": 1,
"godson": 0
},
{
"id": 0,
"godfather": 1,
"godson": 2
}
]
}
Do you have an hint on how I can do this ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

