The concept of "node" in a pack layout is important to understand how pack layout works.
Each node has the following attributes:
{ "name": "flare", "children": [ {"name": "sub1", "size": 3938}, { "name": "sub2", "children": [ {"name": "sub2_sub1", "size": 6714}, {"name": "sub2_sub2", "size": 743} ] } ] }We have 5 objects in the json file:
Object { name: "flare", children: Array[2], depth: 0, value: 11395, y: 478, x: 478, r: 478 } Object { name: "sub1", size: 3938, parent: Object, depth: 1, value: 3938, r: 174.4465055101499, x: 174.4465055101499, y: 478 } Object { name: "sub2", children: Array[2], parent: Object, depth: 1, value: 7457, r: 303.5534944898501, x: 652.4465055101499, y: 478 } Object { name: "sub2_sub1", size: 6714, parent: Object, depth: 2, value: 6714, r: 227.7797367518277, x: 728.2202632481724, y: 478 } Object { name: "sub2_sub2", size: 743, parent: Object, depth: 2, value: 743, r: 75.77375773802244, x: 424.6667687583222, y: 478 }"Node" of the pack corresponds to each object. So we have 5 nodes in this pack layout. "x", "y", "r" and "parent" are already there which means they are computed by pack layout. "name" and "children" are assigned by the dataset in the given json file. The size of each node is controlled by pack.value (Line 40). Note object "flare" does not have a "size" attribute, so its size is the sum of its children's sizes.
No comments:
Post a Comment