d3.nest() key and values conversion to name and children

后端 未结 4 1244
梦谈多话
梦谈多话 2020-12-05 08:31

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

4条回答
  •  隐瞒了意图╮
    2020-12-05 09:15

    Hey guys I think I found a fairly simple solution. I accomplished a very nice nesting of a large dataset (400,000 rows) for a hierarchical bar chart in a very streamline way. It utilizes the Underscore library and an additional function _.nest. Simply download and include the two libraries necessary

    "underscore-min.js" "underscore.nest.js"

    Then use the _.nest function to create your structure. Here's my line:

    var newdata = _.nest(data, ["Material", "StudyName"]);
    

    "Material" and "StudyName" are the columns I want to group my structure to.

    There are other options to use this function if you need to accomplish more things but I will leave it like this

提交回复
热议问题