D3 JSON data conversion

前端 未结 5 1606
一生所求
一生所求 2020-12-01 07:10

I have this JSON data structure:

[
    { \"dep\": \"d1\", \"name\": \"name1\", \"size\": \"size1\" },
    { \"dep\": \"d1\", \"name\": \"name2\", \"size\": \         


        
5条回答
  •  攒了一身酷
    2020-12-01 07:28

    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

    src="underscore-min.js"
    src="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

提交回复
热议问题