Skip to content

Commit db8d305

Browse files
committed
Merge branch 'fix-hierarchy-revalue'
2 parents 61c568f + 6b48969 commit db8d305

File tree

8 files changed

+34
-17
lines changed

8 files changed

+34
-17
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.4.7",
3+
"version": "3.4.8",
44
"main": "d3.js",
55
"scripts": [
66
"d3.js"

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"animation",
1111
"canvas"
1212
],
13-
"version": "3.4.7",
13+
"version": "3.4.8",
1414
"main": "d3.js",
1515
"scripts": [
1616
"d3.js"

d3.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
!function() {
22
var d3 = {
3-
version: "3.4.7"
3+
version: "3.4.8"
44
};
55
if (!Date.now) Date.now = function() {
66
return +new Date();
@@ -6377,11 +6377,16 @@
63776377
return hierarchy;
63786378
};
63796379
hierarchy.revalue = function(root) {
6380-
if (value) d3_layout_hierarchyVisitAfter(root, function(node) {
6381-
var parent;
6382-
node.value = node.children ? 0 : +value.call(hierarchy, node, node.depth) || 0;
6383-
if (parent = node.parent) parent.value += node.value;
6384-
});
6380+
if (value) {
6381+
d3_layout_hierarchyVisitBefore(root, function(node) {
6382+
if (node.children) node.value = 0;
6383+
});
6384+
d3_layout_hierarchyVisitAfter(root, function(node) {
6385+
var parent;
6386+
if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;
6387+
if (parent = node.parent) parent.value += node.value;
6388+
});
6389+
}
63856390
return root;
63866391
};
63876392
return hierarchy;

d3.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "d3",
3-
"version": "3.4.7",
3+
"version": "3.4.8",
44
"description": "A small, free JavaScript library for manipulating documents based on data.",
55
"keywords": [
66
"dom",

src/layout/hierarchy.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,16 @@ d3.layout.hierarchy = function() {
6060

6161
// Re-evaluates the `value` property for the specified hierarchy.
6262
hierarchy.revalue = function(root) {
63-
if (value) d3_layout_hierarchyVisitAfter(root, function(node) {
64-
var parent;
65-
node.value = node.children ? 0 : +value.call(hierarchy, node, node.depth) || 0;
66-
if (parent = node.parent) parent.value += node.value;
67-
});
63+
if (value) {
64+
d3_layout_hierarchyVisitBefore(root, function(node) {
65+
if (node.children) node.value = 0;
66+
});
67+
d3_layout_hierarchyVisitAfter(root, function(node) {
68+
var parent;
69+
if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0;
70+
if (parent = node.parent) parent.value += node.value;
71+
});
72+
}
6873
return root;
6974
};
7075

src/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
!function(){
2-
var d3 = {version: "3.4.7"}; // semver
2+
var d3 = {version: "3.4.8"}; // semver

test/layout/hierarchy-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ suite.addBatch({
2626
nodes = h.children(function() { return null; }).nodes({children: [{}]});
2727
assert.equal(nodes[0].value, 0);
2828
assert.isUndefined(nodes[0].children);
29+
},
30+
"revalue": function(hierarchy) {
31+
var h = hierarchy().sticky(true),
32+
nodes = h.nodes({children: [{children: [{value: 1}, {value: 2}]}, {value: 3}]});
33+
assert.equal(nodes[0].value, 6);
34+
h(nodes[0]); // calls hierarchy.revalue
35+
assert.equal(nodes[0].value, 6);
2936
}
3037
}
3138
});

0 commit comments

Comments
 (0)