var d3 = require('d3')
    , document = require('jsdom').jsdom()
    , xmldom = require('xmldom')
    ;

module.exports = function (data) {
    var svg = d3.select(document.body).append("svg");

    // EDITING STARTS HERE
    var diameter = 960;

    svg.attr("width", diameter)
        .attr("height", diameter - 150)
        .append("g")
        .attr("transform", "translate(" + diameter / 2 + "," + diameter / 2 + ")");

    var tree = d3.layout.tree()
        .size([360, diameter / 2 - 120])
        .separation(function (a, b) {
            return (a.parent == b.parent ? 1 : 2) / a.depth;
        });

    var diagonal = d3.svg.diagonal.radial()
        .projection(function (d) {
            return [d.y, d.x / 180 * Math.PI];
        });

    var nodes = tree.nodes(data),
        links = tree.links(nodes);

    var link = svg.selectAll(".link")
        .data(links)
        .enter().append("path")
        .attr("class", "link")
        .attr("d", diagonal);

    var node = svg.selectAll(".node")
        .data(nodes)
        .enter().append("g")
        .attr("class", "node")
        .attr("transform", function (d) {
            return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")";
        });

    node.append("circle")
        .attr("r", 4.5);

    node.append("text")
        .attr("dy", ".31em")
        .attr("text-anchor", function (d) {
            return d.x < 180 ? "start" : "end";
        })
        .attr("transform", function (d) {
            return d.x < 180 ? "translate(8)" : "rotate(180)translate(-8)";
        })
        .text(function (d) {
            return d.name;
        });

    // EDITING ENDS HERE

    var svgObject = d3.select(document.body).select("svg").attr('xmlns', 'http://www.w3.org/2000/svg');
    return new xmldom.XMLSerializer().serializeToString(svgObject[0][0]);
};
@@ -141,55 +141,186 @@
     
-var svg = d3.select(document.body).append(%22svg%22
+/*%0A    * Use this variable instead of d3.select(%22body%22).append(%22svg%22)%0A    * */%0A    var wrapper = d3.select(document.body).append(%22svg%22).attr('xmlns', 'http://www.w3.org/2000/svg'
 );%0A%0A
@@ -346,16 +346,17 @@
 TS HERE%0A
+%0A
     var 
@@ -376,19 +376,42 @@
 0;%0A%0A    
-svg
+var svg = wrapper%0A        
 .attr(%22w
@@ -1779,133 +1779,107 @@
     
-// EDITING ENDS HERE%0A%0A    var svgObject = d3.select(document.body).select(%22svg%22).attr('xmlns', 'http://www.w3.org/2000/svg');
+d3.select(document.frameElement).style(%22height%22, diameter - 150 + %22px%22);%0A%0A    // EDITING ENDS HERE%0A
 %0A   
@@ -1935,17 +1935,15 @@
 ing(
-svgObject
+wrapper
 %5B0%5D%5B

fix variable svg