chart = (root) => {
const nodeWidth = (width / (root.height + 1)) - 10;
const nodeHeight = 10;
const layOut = d3.tree()
.nodeSize([nodeHeight, nodeWidth]);
layOut(root);
const nodes = root.descendants();
const minNodeY = d3.min(nodes, d => d.x);
const maxNodeY = d3.max(nodes, d => d.x);
const height = (maxNodeY - minNodeY) + (nodeHeight * 2);
const svg = d3.create("svg")
.attr("class", "partial-tree")
.attr("width", width)
.attr("height", height)
const rootX = nodeWidth / 3;
const rootY = nodeHeight + Math.abs(minNodeY);
const plane = svg.append("g")
.attr("class", "plane")
.attr("transform", `translate(${rootX},${rootY})`);
appendLinks(plane, root.links());
appendNodes(plane, nodes);
return svg.node();
}