$(function(){ /* var treeData = [ {"name": "Top Level", "parent": "zero Level", "children": [ { "name": "Level 2: A", "parent": "Top Level", "children": [ { "name": "Son of A", "parent": "Level 2: A" }, { "name": "Daughter of A", "parent": "Level 2: A" } ] }, { "name": "Level 2: B", "parent": "Top Level" } ] }, ]; */ // ************** Generate the tree diagram ***************** var margin = {top: 20, right: 120, bottom: 20, left: 120}, width = 960 - margin.right - margin.left, height = 800 - margin.top - margin.bottom; var i = 0, duration = 750, root; var tree = d3.layout.tree() .size([height, width]); var diagonal = d3.svg.diagonal() .projection(function(d) { return [d.y, d.x]; }); var svg = d3.select("body").append("svg") .attr("width", width + margin.right + margin.left) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); /********************** get the json ***************************/ var datajson; var treeData=[]; var datajsonArray = []; function objectData(name, parent, children) { this.name = name; this.parent = parent; this.children = children; }; d3.json("convertcsvMEDIA.json", function(error, json) { if (error) return console.warn(error); datajson = json; treeData.push(new objectData("Qui possède quoi?","none",datajsonArray)) for (var prop in datajson) { // console.log("prop is ",prop); var newdatajsonprop= []; for (var i=0;i