Like the chrome dev tool's screen shot below, I'd tried
console.log(object)
to print the total attributes of the object. But I can't access the "depth" through
object.depth
but I was able to get the object's name,value,count in the meantime..
I was wondering what exactly the attr "depth" is.
The source code is from a D3.js tree demo in this post: D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.
However, I was trying to customize the algorithm of caculating the the node's width, using each level of the node's max label length instead of the total tree's.
// Call visit function to establish maxLabelLength
visit(treeData, function(d) {
totalNodes++;
maxLabelLength = Math.max(d.name.length, maxLabelLength);
console.log(d); //I was debuging here
}, function(d) {
return d.children && d.children.length > 0 ? d.children : null;
});