diseaseTreeChart = {
const width = 800;
const dx = 50;
const dy = 140;
const root = d3.hierarchy(diseaseTreeData);
const treeLayout = d3.tree().nodeSize([dx, dy]);
treeLayout(root);
const x0 = d3.min(root.descendants(), d => d.x);
const x1 = d3.max(root.descendants(), d => d.x);
const y0 = d3.min(root.descendants(), d => d.y);
const y1 = d3.max(root.descendants(), d => d.y);
const svg = d3.create("svg")
.attr("viewBox", [y0 - 100, x0 - dx - 60, y1 - y0 + 200, x1 - x0 + 160])
.attr("preserveAspectRatio", "xMidYMid meet")
.style("font", "12px sans-serif")
.style("overflow", "visible")
.style("width", "100%")
.style("height", "auto");
const g = svg.append("g");
g.append("text")
.attr("x", (y1 - y0) / 2 + y0)
.attr("y", x0 - dx - 30)
.attr("text-anchor", "middle")
.attr("font-size", "25px")
.attr("font-weight", "bold")
.text("Common Disease Co-Occurrence Tree");
g.append("g")
.selectAll("path")
.data(root.links())
.join("path")
.attr("fill", "none")
.attr("stroke", "#ccc")
.attr("stroke-width", 2)
.attr("d", d3.linkHorizontal()
.x(d => d.y)
.y(d => d.x)
);
const node = g.append("g")
.selectAll("g")
.data(root.descendants())
.join("g")
.attr("transform", d => `translate(${d.y},${d.x})`);
node.append("circle")
.attr("fill", "#4e79a7")
.attr("r", 5);
node.append("text")
.attr("dy", "0.31em")
.attr("x", d => d.children ? -10 : 10)
.attr("text-anchor", d => d.children ? "end" : "start")
.text(d => `${d.data.name} (${d.data.count})`)
.clone(true).lower()
.attr("stroke", "white");
return svg.node();
}