queue() .defer(d3.csv,"sampleData.csv") .await(ready); var height = document.getElementById("tree-container").offsetHeight; var width = document.getElementById("tree-container").offsetWidth; var avatarRadius = 20; var translateOffset = 25; var radius = d3.min([height,width]) / 2; var cluster = d3.layout.cluster() .size([360, radius/1.33]) // .separation(function(a,b){return (a.parent == b.parent ? 1:2)/a.depth;}); var svg = d3.select("#tree-container").append("svg") .attr("width", radius * 2) .attr("height", radius * 2) .attr("id","tree-container-svg") .append("g") .attr("transform", "translate(" + radius + "," + height/2 + ")"); //Clip path needed for cicrular SVG avatars var defs = svg.append('defs'); var clipPath = defs.append('clipPath') .attr('id', 'clip-circle') .append('circle') .attr('r', avatarRadius-2.5); var diagonal = d3.svg.diagonal.radial() .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; }); d3.selection.prototype.moveToFront = function() { return this.each(function() { this.parentNode.appendChild(this); }); }; d3.selection.prototype.moveToBack = function() { return this.each(function() { var firstChild = this.parentNode.firstChild; if (firstChild) { this.parentNode.insertBefore(this, firstChild); } }); }; //http://www.d3noob.org/2014/01/tree-diagrams-in-d3js_11.html function treeify(list,callback) { var dataMap = list.reduce(function(map, node) { map[node.Associate] = node; return map; }, {}); var treeData = []; list.forEach(function(node) { //Assuming the highest node is the last in the csv file if(node.Manager===node.Associate){ node.Manager = "Board of Directors" callback(node); } // add to parent var parent = dataMap[node.Manager]; if (parent) { // create child array if it doesn't exist (parent.children || (parent.children = [])) // add node to child array .push(node); } else { // parent is null or missing treeData.push(node); } }); }; function findItem(root,name,callback){ var stack=[]; stack.push(root); while(stack.length!==0){ var element = stack.pop(); if(element.Associate ===name){ callback(element); return; } //The up, uncompressed case else if(element.children!==undefined && element.children.length>0){ for(var i=0; i0){ for(var j=0; j