chart = {
const data = getData(parentIDs)
const SQRT3 = Math.sqrt(3)
const hexagonPoly = [[0,-1],[SQRT3/2,0.5],[0,1],[-SQRT3/2,0.5],[-SQRT3/2,-0.5],[0,-1],[SQRT3/2,-0.5]];
function generateHexagon(hexRadius){
const hexagonPath = "m" + hexagonPoly.map(function(p){ return [p[0]*hexRadius, p[1]*hexRadius].join(','); }).join('l') + "z";
return hexagonPath
}
const svg = d3.create("svg")
.attr('width', 500)
.attr('height', 500)
.style("font", "10px sans-serif")
.style("overflow", "visible")
.attr("text-anchor", "middle");
const node = svg.append("g")
.attr("pointer-events", "all")
.selectAll("g")
.data(data)
.join("g")
.attr("transform", d => `translate(${d.x},${d.y})`);
node.append("path")
.attr("id", d => (d.circleUid = DOM.uid("circle")).id)
.attr("d", d => circle(d.r + 3))
.attr("display", "none")
node.filter(d => d.height === 1).append("circle")
.attr('class', 'nodeWrapper')
.attr("r", d => d.r)
.attr("stroke", "black")
.attr("fill", d => d.children ? "none" : "black")
.attr("pointer-events", d => d.children ? "all" : "none");
node.filter(d => d.height === 0).append("path")
.attr('class', 'hexagon')
.attr("d", d => generateHexagon(d.r+4))
.attr("stroke", "black")
.attr("fill", d => d.children ? "none" : "black")
.attr("pointer-events", d => d.children ? "all" : "none");
node.filter(d => d.height === 1).append("text")
.attr("fill", "black")
.append("textPath")
.attr("xlink:href", d => d.circleUid.href)
.attr("startOffset", "50%")
.attr('font-size', '12px')
.text(d => d.data.id);
node.filter(d => d.height === 0).append("text")
.attr("fill", "#fff")
.attr('font-size', '16px')
.text(d => d.data.id)
return svg.attr("viewBox", autoBox).node();
}