I already solved it but i forget to post answer
here after the tree manage it's own layout if you want to split them by row
var tree = d3.layout.tree()
.separation(function(a, b) {
return a.parent === b.parent ? 1 : 0.8;
})
.nodeSize([200,200]);
var _nodesData = tree.nodes(rootObject);
// _nodesData.forEach(function(d) { d.y = d.depth * 220;});
_nodesData.forEach(function (d) {
d.y = d.depth * 220;
if (d.children) {
d.children.forEach(function (d, i) {
d.x = d.parent.x - (d.parent.children.length-1)*200/30
+ (d.parent.children.indexOf(d))*200/10 - i % 10 * 100 ;
});
}
});
here 200 is space between each child and 10 is number of child per each row
and obviously this make your next level child override issue for that you can save last max Y and max X on each level and use for starting point of next level just like next code
var tree1 = d3.layout.tree()
.separation(function(a, b) {
return a.parent === b.parent ? 1.5 : 1.5;
})
.nodeSize([150,200]);
var _nodesData1 = tree1.nodes(_newRecordData[_x]);
_nodesData1.forEach(function (d) {
var _midpoint = d.x;
var _newRowPoint = d.x - ( 170 * 3.5)
var _countInRow = 7;
var _k = 0;
var previousTextLong = false;
var previousDirection = 1;
// if the node has too many children, go in and fix their positions to two columns.
if (d.children && d.children.length > 8) {
var _previousX = _newRowPoint;
var _previousY = d.children[0].y;
d.children.forEach(function (d, i) {
d.x = _previousX;
var s = 0;
if(previousTextLong){
s = 20*previousDirection;
}
d.y = _previousY + s;
if(d.name && d.name.length > 25){
previousTextLong = true;
previousDirection = previousDirection * -1;
}else{
previousTextLong = false;
}
_k++;
if(_k == 8){
_k = 0;
_previousX = _newRowPoint;
_previousY = _previousY + 200;
}else{
_previousX = _previousX + 170;
}
});
}
});
I think this give more customization for positions... I use multiple tree layout in one diagram and manage them after node positions are made ...