source:
node_modules/d3-hierarchy/src/hierarchy/sum.js
| Last change on this file was e4c61dd, checked in by , 6 months ago | |
|---|---|
|
|
| File size: 264 bytes | |
| Rev | Line | |
|---|---|---|
| [e4c61dd] | 1 | export default function(value) { |
| 2 | return this.eachAfter(function(node) { | |
| 3 | var sum = +value(node.data) || 0, | |
| 4 | children = node.children, | |
| 5 | i = children && children.length; | |
| 6 | while (--i >= 0) sum += children[i].value; | |
| 7 | node.value = sum; | |
| 8 | }); | |
| 9 | } |
Note:
See TracBrowser
for help on using the repository browser.
