I am working on creating a Treemap from a csv file.
The data in the csv file is hierarchical, as a result I used d3.nest()
.
However, the resulting JSON is in the form of {key:"United States", values:[...]}
.
The zoom-able treemap requires hierarchy as {name:"United States", children:[...]}
.
I have tried replacing name and children to key and values in the example, but it doesn't work.
If anyone has already looked into using key and values on a zoomable treemap, please help. I am new to D3 and I don't know whether d.children means structure or value from the data.
This is the code to convert World Continents, Regions, and Countries from CSV to a hierarchy using d3.
$ d3.csv("../Data/WorldPopulation.csv", function (pop) {
var treeData= { "key": "World", "values": d3.nest()
.key(function (d) { return d.Major_Region; })
.key(function (d) { return d.Region; })
.key(function (d) { return d.Country; })
.entries(pop)
};
The first few lines of the result is:
`[{"key":"AFRICA","values":[{"key":"Eastern Africa","values"
[{"key":"Burundi","values":[.........`
I can not use the zoomable treemap because it requires name and children labels in json rather than key and values.