Attempting to build a d3.js tree, I need my data to be in hierarchical form before using d3.treeLayout.
Currently, here is what my json array looks like:
var data = [
{"group":"1","price":"36599.88", "cy":"44260"},
{"group":"2","price":"36599.88", "cy":"44260"},
{"group":"3","price":"36599.88", "cy":"44260"},
{"group":"4","price":"36599.88", "cy":"44260"},
{"group":"1","price":"1241.88", "cy":"44260"},
{"group":"2","price":"36595429.88", "cy":"44260"},
{"group":"3","price":"12124.88", "cy":"44260"},
{"group":"4","price":"6264.88", "cy":"44260"},
]
Utilizing the d3.nest() function to group the entries:
var NestedBudget = d3.nest()
.key(function(d){
return d.group;
})
.entries(data);
Unfortunately, this structured data does not work when passed to d3.hierarchy(). https://i.sstatic.net/913jy.png
I have included an image of the result obtained after passing it to
var root_data = d3.hierarchy(data);
I hope this explanation is clear. Any assistance would be greatly appreciated.