|
4630 | 4630 | } |
4631 | 4631 | d3.layout.hierarchy = function() { |
4632 | 4632 | var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; |
4633 | | - function recurse(data, depth, nodes) { |
4634 | | - var childs = children.call(hierarchy, data, depth), node = d3_layout_hierarchyInline ? data : { |
4635 | | - data: data |
4636 | | - }; |
| 4633 | + function recurse(node, depth, nodes) { |
| 4634 | + var childs = children.call(hierarchy, node, depth); |
4637 | 4635 | node.depth = depth; |
4638 | 4636 | nodes.push(node); |
4639 | 4637 | if (childs && (n = childs.length)) { |
|
4647 | 4645 | if (sort) c.sort(sort); |
4648 | 4646 | if (value) node.value = v; |
4649 | 4647 | } else if (value) { |
4650 | | - node.value = +value.call(hierarchy, data, depth) || 0; |
| 4648 | + node.value = +value.call(hierarchy, node, depth) || 0; |
4651 | 4649 | } |
4652 | 4650 | return node; |
4653 | 4651 | } |
|
4657 | 4655 | var i = -1, n, j = depth + 1; |
4658 | 4656 | while (++i < n) v += revalue(children[i], j); |
4659 | 4657 | } else if (value) { |
4660 | | - v = +value.call(hierarchy, d3_layout_hierarchyInline ? node : node.data, depth) || 0; |
| 4658 | + v = +value.call(hierarchy, node, depth) || 0; |
4661 | 4659 | } |
4662 | 4660 | if (value) node.value = v; |
4663 | 4661 | return v; |
|
4690 | 4688 | }; |
4691 | 4689 | function d3_layout_hierarchyRebind(object, hierarchy) { |
4692 | 4690 | d3.rebind(object, hierarchy, "sort", "children", "value"); |
| 4691 | + object.nodes = object; |
4693 | 4692 | object.links = d3_layout_hierarchyLinks; |
4694 | | - object.nodes = function(d) { |
4695 | | - d3_layout_hierarchyInline = true; |
4696 | | - return (object.nodes = object)(d); |
4697 | | - }; |
4698 | 4693 | return object; |
4699 | 4694 | } |
4700 | 4695 | function d3_layout_hierarchyChildren(d) { |
|
4716 | 4711 | }); |
4717 | 4712 | })); |
4718 | 4713 | } |
4719 | | - var d3_layout_hierarchyInline = false; |
4720 | 4714 | d3.layout.pack = function() { |
4721 | 4715 | var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ]; |
4722 | 4716 | function pack(d, i) { |
|
0 commit comments