Facebook
From Hot Earthworm, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 42
  1.          var jsonResponse = '{"businessConnections":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnections","businessConnection":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnection","vo-list-item":"1","sharesPercentage":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"100","precision":"2","fractionPart":"0"},"connectionType":"BENEFICIARY","detailIdentificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"C55RS116","identificationType":"SEGMENT_NAME"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3056621","identificationType":"DE_BWI_ONR"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"1","identificationType":"SEQUENCE_NUMBER"}]},"detailEntity":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEntity","addresses":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddresses","address":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddress","vo-list-item":"1","location":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","zip":"14513","street":"Dorfstr.","houseNumber":"10","city":"Teltow","country":"DEU","houseNumberAdd":"Ruhlsdorf"},"contacts":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContacts","POBoxes":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBoxes","POBox":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBox","vo-list-item":"1","boxLocation":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","country":"DEU"}}},"phones":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhones","phone":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhone","vo-list-item":"1","type":"PHONE","number":"03328/474174"}}},"name":"Dimer","firstName":"Christoph","birthDate":{"vo-class":"com.deltavista.cos.vo.IDVDate","content":"19590420"},"type":"MAIN_ADDRESS"}}}},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnection","vo-list-item":"1","sharesPercentage":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"0","precision":"2","fractionPart":"0"},"connectionType":"BENEFICIARY","detailIdentificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"C55RS116","identificationType":"SEGMENT_NAME"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3056617","identificationType":"DE_BWI_ONR"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"2","identificationType":"SEQUENCE_NUMBER"}]},"detailEntity":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEntity","addresses":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddresses","address":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddress","vo-list-item":"1","location":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","zip":"09603","street":"Nordstr.","houseNumber":"4","city":"GroƟschirma","country":"DEU"},"contacts":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContacts","POBoxes":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBoxes","POBox":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBox","vo-list-item":"1","boxLocation":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","country":"DEU"}}},"phones":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhones","phone":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhone","vo-list-item":"1","type":"PHONE","number":"035242/4660"}}},"name":"Dimer Immobilien Verwaltungsgesellschaft mbH","type":"MAIN_ADDRESS"}}}},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnection","vo-list-item":"1","sharesPercentage":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"74","precision":"2","fractionPart":"0"},"connectionType":"BENEFICIARY","detailIdentificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"C55RS116","identificationType":"SEGMENT_NAME"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"50473321","identificationType":"DE_BWI_ONR"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3","identificationType":"SEQUENCE_NUMBER"}]},"detailEntity":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEntity","addresses":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddresses","address":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddress","vo-list-item":"1","location":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","zip":"09603","street":"Nordstr.","houseNumber":"4","city":"GroƟschirma","country":"DEU"},"name":"Dimer Immobilien GmbH & Co. KG","type":"MAIN_ADDRESS"}}}},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnection","vo-list-item":"1","sharesPercentage":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"0","precision":"2","fractionPart":"0"},"connectionType":"BENEFICIARY","detailIdentificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"C55RS116","identificationType":"SEGMENT_NAME"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3045173","identificationType":"DE_BWI_ONR"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"4","identificationType":"SEQUENCE_NUMBER"}]},"detailEntity":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEntity","addresses":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddresses","address":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddress","vo-list-item":"1","identificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"DE136757339","identificationType":"EU_VAT_NUMBER"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3220011402686","identificationType":"EU_TAX_ELSTER_NUMBER"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"220/114/02686","identificationType":"EU_TAX_NUMBER"}]},"location":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","zip":"09603","street":"Nordstr.","geopoint":{"vo-class":"com.deltavista.sdk.datamodel.IDVGeopoint","latitude":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"51","precision":"6","fractionPart":"34535"},"longitude":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"13","precision":"6","fractionPart":"304565"}},"houseNumber":"4","city":"GroƟschirma","country":"DEU","houseNumberAdd":"ST Siebenlehn"},"contacts":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContacts","POBoxes":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBoxes","POBox":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBox","vo-list-item":"1","boxLocation":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","country":"DEU"}}},"WWWs":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IWWWs","WWW":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContactData","vo-list-item":"1","type":"WWW","contactData":"www.montara.biz"}},"emails":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEmails","email":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContactData","vo-list-item":"1","type":"EMAIL","contactData":"info@montara.biz"}},"phones":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhones","phone":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhone","vo-list-item":"1","type":"PHONE","number":"035242/4660"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhone","vo-list-item":"1","type":"FAX","number":"035242/46642"}]}},"name":"Montara Verpacken mit System GmbH","type":"MAIN_ADDRESS"}}}},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnection","vo-list-item":"1","sharesPercentage":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"100","precision":"2","fractionPart":"0"},"connectionType":"BENEFICIARY","detailIdentificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"C55RS116","identificationType":"SEGMENT_NAME"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3056621","identificationType":"DE_BWI_ONR"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"1","identificationType":"SEQUENCE_NUMBER"}]},"detailEntity":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEntity","addresses":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddresses","address":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddress","vo-list-item":"1","location":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","zip":"14513","street":"Dorfstr.","houseNumber":"10","city":"Teltow","country":"DEU","houseNumberAdd":"Ruhlsdorf"},"contacts":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContacts","POBoxes":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBoxes","POBox":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBox","vo-list-item":"1","boxLocation":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","country":"DEU"}}},"phones":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhones","phone":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhone","vo-list-item":"1","type":"PHONE","number":"03328/474174"}}},"name":"Dimer","firstName":"Christoph","birthDate":{"vo-class":"com.deltavista.cos.vo.IDVDate","content":"19590420"},"type":"MAIN_ADDRESS"}}}},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnection","vo-list-item":"1","sharesPercentage":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"74","precision":"2","fractionPart":"0"},"connectionType":"BENEFICIARY","detailIdentificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"C55RS116","identificationType":"SEGMENT_NAME"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"50473321","identificationType":"DE_BWI_ONR"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"2","identificationType":"SEQUENCE_NUMBER"}]},"detailEntity":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEntity","addresses":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddresses","address":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddress","vo-list-item":"1","location":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","zip":"09603","street":"Nordstr.","houseNumber":"4","city":"GroƟschirma","country":"DEU"},"name":"Dimer Immobilien GmbH & Co. KG","type":"MAIN_ADDRESS"}}}},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IBusinessConnection","vo-list-item":"1","sharesPercentage":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"0","precision":"2","fractionPart":"0"},"connectionType":"BENEFICIARY","detailIdentificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"C55RS116","identificationType":"SEGMENT_NAME"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3045173","identificationType":"DE_BWI_ONR"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3","identificationType":"SEQUENCE_NUMBER"}]},"detailEntity":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEntity","addresses":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddresses","address":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IAddress","vo-list-item":"1","identificationEntries":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntries","identificationEntry":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"DE136757339","identificationType":"EU_VAT_NUMBER"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"3220011402686","identificationType":"EU_TAX_ELSTER_NUMBER"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IIdentificationEntry","vo-list-item":"1","ID":"220/114/02686","identificationType":"EU_TAX_NUMBER"}]},"location":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","zip":"09603","street":"Nordstr.","geopoint":{"vo-class":"com.deltavista.sdk.datamodel.IDVGeopoint","latitude":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"51","precision":"6","fractionPart":"34535"},"longitude":{"vo-class":"com.deltavista.sdk.datamodel.IDVDecimal","integerPart":"13","precision":"6","fractionPart":"304565"}},"houseNumber":"4","city":"GroƟschirma","country":"DEU","houseNumberAdd":"ST Siebenlehn"},"contacts":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContacts","POBoxes":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBoxes","POBox":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPOBox","vo-list-item":"1","boxLocation":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.ILocation","country":"DEU"}}},"WWWs":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IWWWs","WWW":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContactData","vo-list-item":"1","type":"WWW","contactData":"www.montara.biz"}},"emails":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IEmails","email":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IContactData","vo-list-item":"1","type":"EMAIL","contactData":"info@montara.biz"}},"phones":{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhones","phone":[{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhone","vo-list-item":"1","type":"PHONE","number":"035242/4660"},{"vo-class":"com.deltavista.dsp.entity.v2_0.datamodel.IPhone","vo-list-item":"1","type":"FAX","number":"035242/46642"}]}},"name":"Montara Verpacken mit System GmbH","type":"MAIN_ADDRESS"}}}}]}}';
  2.  
  3. var obj = JSON.parse(jsonResponse);
  4. var businessConnection = obj.businessConnections.businessConnection;
  5.  
  6. var data={
  7.     nodes:[],
  8.     links:[]
  9. };
  10.  
  11. var name, children, type, position, address;
  12.  
  13. for(var i = 0; i < 4; i++) {
  14.     if(businessConnection[i].connectionType === "BENEFICIARY") {
  15.             address = businessConnection[i].detailEntity.addresses.address;
  16.             //name = address.firstName + " " + address.name;
  17.             name = i;
  18.             type = "\uf2bd";
  19.  
  20.         data.nodes.push({
  21.             "id": i,
  22.             "name": name,
  23.             "lvl": (i+1).toString(),
  24.             "children": "0",
  25.             "type": type,
  26.             "position": businessConnection[i].functionID
  27.         });
  28.     }
  29. }
  30.  
  31. // console.log(data.nodes);
  32.  
  33. //90px between 2 elements + 10px free per element
  34. var height = data.nodes.length * 100 + 100;
  35. var width = data.nodes.length * 100 + 100;
  36.  
  37. addAdditionalNodes(data);
  38. setAll(data);
  39. prepareLinks(data);
  40.  
  41. var svg = d3.select("body").append("svg")
  42.     .attr("height", height);
  43.  
  44. var force = d3.layout.force()
  45.     .nodes(data.nodes)
  46.     .links(data.links)
  47.     .size([width, height])
  48.     .on("tick", tick)
  49.     .start();
  50.  
  51. var link = svg.selectAll(".link")
  52.    .data(data.links)
  53.  .enter().append("line")
  54.    .attr("class", "link");
  55.  
  56. var g = svg.selectAll(".node")
  57.     .data(data.nodes)
  58.     .enter().append("g")
  59.     .attr("class", function (d) {return "node-" + d.lvl});
  60.  
  61. g.append("circle")
  62.     .attr("r","30px" )
  63.     .style("fill", function (d) {
  64.         if(d.lvl[0] !== "0") {
  65.             return "gray";
  66.         }
  67.         return "transparent";
  68.     });
  69.  
  70. var icon = g.append('text')
  71.     .data(data.nodes)
  72.     .attr("dy", "14px" )
  73.     .attr("dx", function (d) {
  74.         if(d.type === "\uf1ad") return "-16px";
  75.         else return "-21px";
  76.     } )
  77.     .attr('font-family', 'FontAwesome')
  78.     .attr("fill",function (d)  { return "#fff";} )
  79.     .attr('font-size', "300%" )
  80.     .text(function(d) { return d.type})
  81.     .style("cursor","default")
  82.     .style("stroke-width","0px");
  83.  
  84. var textName = g.append('text')
  85.     .data(data.nodes)
  86.     .attr("dy", "42px")
  87.     .attr("dx", "35px")
  88.     .attr('font-size', "100%" )
  89.     .attr("text-anchor", "middle")
  90.     .text(function(d) { return d.name.split("_")[0] })
  91.     .style("cursor","default")
  92.     .style("stroke-width","0px");
  93.  
  94.  
  95. var textPosition = g.append('text')
  96.     .data(data.nodes)
  97.     .attr("class", "position")
  98.     .attr("lengthAdjust", "spacingAndGlyphs")
  99.     .attr("textLength", "100")
  100.     .attr("text-anchor", "middle")
  101.     .attr("dy", function (d) {
  102.         if(d.lvl !== "1") return "-5px";
  103.     })
  104.     .attr("dx", function (d) {
  105.         if(d.lvl !== "1") return "-95px";
  106.     })
  107.     .style("cursor","default")
  108.     .text(function(d) { return d.position})
  109.     .style("font-size", "9px")
  110.     .style("stroke-width","0px")
  111.     .append('svg:tspan')
  112.     .style("font-size", "9px")
  113.     .attr("y", function (d) {
  114.         if(d.lvl !== "1") return "15px";
  115.     })
  116.     .attr("x", function (d) {
  117.         if(d.lvl !== "1") return "-95px";
  118.     })
  119.     .text(function(d) { return "XX%" });
  120.  
  121. console.log(data.nodes);
  122. console.log(data.links);
  123.  
  124. function tick() {
  125.     link
  126.         .attr("x1", function(d) { return d.source.x; })
  127.         .attr("y1", function(d) { return d.source.y; })
  128.         .attr("x2", function(d) { return d.target.x; })
  129.         .attr("y2", function(d) { return d.target.y; });
  130.  
  131.     g
  132.         .attr("transform", function transform(d) { return "translate(" + d.x + "," + d.y + ")"; });
  133. }
  134.  
  135. function setAll(data) {
  136.     var distanceX = 150,
  137.         distanceY = 90,
  138.         plusY = distanceY,
  139.         nodes = data.nodes;
  140.  
  141.     //set main node
  142.     nodes[0].fixed = "TRUE";
  143.     nodes[0].x = distanceX - 70;
  144.     nodes[0].y = distanceY;
  145.  
  146.     //set rest of nodes
  147.     for(var i = 1; i < nodes.length; i++) {
  148.         nodes[i].fixed = "TRUE";
  149.         var level = nodes[i].lvl
  150.         if (level.charAt(0) === "0") {
  151.             nodes[i].x = distanceX * parseInt(level.charAt(1)) - 70;
  152.             nodes[i].y = distanceY + plusY;
  153.         } else {
  154.             distanceY += 90
  155.             nodes[i].x = distanceX * parseInt(level) - 70;
  156.             nodes[i].y = distanceY;
  157.         }
  158.     }
  159. }
  160.  
  161. function addAdditionalNodes(data) {
  162.     var nodes = data.nodes,
  163.         name,
  164.         lvl;
  165.  
  166.     for(var i = 0; i < nodes.length - 1; i++) {
  167.         lvl = "0" + nodes[i].lvl.toString() + nodes[i+1].lvl.toString()
  168.         name = nodes[i].name + "1";
  169.         nodes.splice(++i, 0, {"name":name, "lvl": lvl, "children": 0});
  170.     }
  171. }
  172.  
  173. function prepareLinks(data) {
  174.     var nodes = data.nodes,
  175.         links = data.links,
  176.         src = "",
  177.         trg = "";
  178.  
  179.     for(var i = 0; i < nodes.length - 1; i++) {
  180.         src = nodes[i];
  181.         trg = nodes[i+1];
  182.         links.push({ "source": src, "target": trg });
  183.     }
  184. }
  185.