descendants() is a hierarchy-node method that returns an array containing the current node and every node below it in the tree. It works on hierarchies created from CSV data with d3.stratify() or hierarchical JSON with d3.hierarchy(). section 11.1.2 section 11.1.1
Collecting every language node
Convert hierarchical JSON into a root node, then call root.descendants(). The resulting array includes Languages, Indo-European, Germanic, English, and the other nodes in the hierarchy. Keep leaves() separate when you need only nodes without children. section 11.1.2 section 11.5
{
"name": "Languages",
"children": [
{
"name": "Indo-European",
"children": [
{
"name": "Germanic",
"children": [
{
"name": "English"
}
]
},
{
"name": "Indo-Aryan",
"children": [
{
"name": "Hindi"
}
]
},
{
"name": "Romance",
"children": [
{
"name": "Spanish"
},
{
"name": "French"
}
]
},
]
},
{
"name": "Sino-Tibetan",
"children": [
{
"name": "Sinitic",
"children": [
{
"name": "Mandarin Chinese"
}
]
}
]
}
]
}
Use the nested language dataset to trace which nodes descendants() will return. section 11.1.2
