Hey guys,
actually I didn’t start learning D3.js yet, but it seems very promising.
For a start I wanted to visualize nested JSON objects as a tree.
All examples I found on observable use JSON objects with explicit hierarchy information in their attributes, for example the children attribute:
{
"name":"Alex",
"children":[
{
"name":"Josh",
"children":[
{
"name":"Joelle"
}
]
},
{
"name":"David",
"children":[
{
"name":"Lina"
},
{
"name":"Martha"
}
]
},
{
"name":"Lara",
"children":[
]
}
]
}
But actually, hierarchy is implicitly included in the JSON notation, so why is this needed?
Is it possible, and are there any examples to visualize JSON data as following as a tree?
{
"fruit":"Apple",
"vitamins":[
{
"name":"Vitamin C",
"consistsOf":[
{
"id":"H",
"name":"Hydrogen",
"colors":[
{
"name":"colorless"
}
]
},
{
"id":"O",
"name":"Oxygen",
"colors":[
{
"name":"colorless"
},
{
"name":"blue"
}
]
}
]
},
{
"name":"Vitamin D",
"consistsOf":[
{
"id":"H",
"name":"Hydrogen",
"colors":[
{
"name":"colorless"
}
]
},
{
"id":"O",
"name":"Oxygen",
"colors":[
{
"name":"colorless"
},
{
"name":"blue"
}
]
},
{
"id":"C",
"name":"Carbon",
"colors":[
{
"name":"black"
},
{
"name":"grey"
}
]
}
]
}
]
}