Родитель
f90bc4fd50
Коммит
d024c3f82c
|
@ -1027,12 +1027,12 @@ d3.layout.hierarchy = function() {
|
||||||
// Also converts the data representation into a standard hierarchy structure.
|
// Also converts the data representation into a standard hierarchy structure.
|
||||||
function recurse(data, depth, nodes) {
|
function recurse(data, depth, nodes) {
|
||||||
var childs = children.call(hierarchy, data, depth),
|
var childs = children.call(hierarchy, data, depth),
|
||||||
|
n,
|
||||||
node = d3_layout_hierarchyInline ? data : {data: data};
|
node = d3_layout_hierarchyInline ? data : {data: data};
|
||||||
node.depth = depth;
|
node.depth = depth;
|
||||||
nodes.push(node);
|
nodes.push(node);
|
||||||
if (childs) {
|
if (childs && (n = childs.length)) {
|
||||||
var i = -1,
|
var i = -1,
|
||||||
n = childs.length,
|
|
||||||
c = node.children = [],
|
c = node.children = [],
|
||||||
v = 0,
|
v = 0,
|
||||||
j = depth + 1;
|
j = depth + 1;
|
||||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -7,12 +7,12 @@ d3.layout.hierarchy = function() {
|
||||||
// Also converts the data representation into a standard hierarchy structure.
|
// Also converts the data representation into a standard hierarchy structure.
|
||||||
function recurse(data, depth, nodes) {
|
function recurse(data, depth, nodes) {
|
||||||
var childs = children.call(hierarchy, data, depth),
|
var childs = children.call(hierarchy, data, depth),
|
||||||
|
n,
|
||||||
node = d3_layout_hierarchyInline ? data : {data: data};
|
node = d3_layout_hierarchyInline ? data : {data: data};
|
||||||
node.depth = depth;
|
node.depth = depth;
|
||||||
nodes.push(node);
|
nodes.push(node);
|
||||||
if (childs) {
|
if (childs && (n = childs.length)) {
|
||||||
var i = -1,
|
var i = -1,
|
||||||
n = childs.length,
|
|
||||||
c = node.children = [],
|
c = node.children = [],
|
||||||
v = 0,
|
v = 0,
|
||||||
j = depth + 1;
|
j = depth + 1;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
require("../env");
|
||||||
|
require("../../d3");
|
||||||
|
require("../../d3.layout");
|
||||||
|
|
||||||
|
var vows = require("vows"),
|
||||||
|
assert = require("assert");
|
||||||
|
|
||||||
|
var suite = vows.describe("d3.layout.hierarchy");
|
||||||
|
|
||||||
|
suite.addBatch({
|
||||||
|
"hierarchy": {
|
||||||
|
topic: d3.layout.hierarchy,
|
||||||
|
"doesn't overwrite the value of a node that has an empty children array": function(hierarchy) {
|
||||||
|
assert.deepEqual(hierarchy({value: 1, children: []}), [
|
||||||
|
{data: {value: 1, children: []}, depth: 0, value: 1}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
suite.export(module);
|
Загрузка…
Ссылка в новой задаче