Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Pack Siblings and Enclosure
// -----------------------------------------------------------------------
interface CircleData extends d3Hierarchy.PackCircle {
v: string;
}
let circles: Array = [
{ r: 10, v: 'a' },
{ r: 1, v: 'b' },
{ r: 20, v: 'c' }
];
// packSiblings
circles = d3Hierarchy.packSiblings(circles);
// packEnclose
let enclosure: { r: number, x: number, y: number };
enclosure = d3Hierarchy.packEnclose(circles);
// Pack Siblings and Enclosure
// -----------------------------------------------------------------------
interface CircleData extends d3Hierarchy.PackCircle {
v: string;
}
let circles: Array = [
{ r: 10, v: 'a' },
{ r: 1, v: 'b' },
{ r: 20, v: 'c' }
];
// packSiblings
circles = d3Hierarchy.packSiblings(circles);
// packEnclose
let enclosure: { r: number, x: number, y: number };
enclosure = d3Hierarchy.packEnclose(circles);
const textWidth =
fontWidth * d._NWFText.length * calcualatedNodeSize * 1.4
const textHeight = fontSize * calcualatedNodeSize
d.textHeight = textHeight + 4
d.textWidth = textWidth + 4
d.rotate = rotate ? rotate(d, i) : 0
d.fontSize = fontSize * calcualatedNodeSize
d.fontWeight = fontWeight
d.radius = d.r = textWidth / 2
})
projectedNodes.sort((a, b) => b.textWidth - a.textWidth)
//bubblepack for initial position
packSiblings(projectedNodes)
// if (rotate) {
const collide = bboxCollide(d => {
if (d.rotate) {
return [
[-d.textHeight / 2, -d.textWidth / 2],
[d.textHeight / 2, d.textWidth / 2]
]
}
return [
[-d.textWidth / 2, -d.textHeight / 2],
[d.textWidth / 2, d.textHeight / 2]
]
}).iterations(1)
const xCenter = size[0] / 2