d3.js_Hierachy

linked to Datenbank
-> d3.js

Hierarchy

Before you can compute a hierarchical layout, you need a root node. If your data is already in a hierarchical format, such as JSON, you can pass it directly to d3.hierarchy; otherwise, you can rearrange tabular data, such as comma-separated values (CSV), into a hierarchy using d3.stratify.

# d3.hierarchy(data[, children]) ยท SourceExamples

Constructs a root node from the specified hierarchical data. The specified data must be an object representing the root node. For example:

{ {
"name": "Eve",
"children": [

{
  "name": "Cain"
},
{
  "name": "Seth",
  "children": [
    {
      "name": "Enos"
    },
    {
      "name": "Noam"
    }
  ]
},
{
  "name": "Abel"
},
{
  "name": "Awan",
  "children": [
    {
      "name": "Enoch"
    }
  ]
},
{
  "name": "Azura"
}

]
}}

The specified children accessor function is invoked for each datum, starting with the root data, and must return an iterable of data representing the children, if any. If the children accessor is not specified, it defaults to:

function children(d) {
return d.children;
}

If data is a Map, it is implicitly converted to the entry [undefined, data], and the children accessor instead defaults to:

function children(d) {
return Array.isArray(d) ? d[1] : null;
}

This allows you to pass the result of d3.group or d3.rollup to d3.hierarchy.