Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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);
nonleafChildren.forEach((node) => {
node.labelSize = Math.min(labelSize, getLabelSize(maxLabelRatio)(node));
node.r += node.labelSize / 2;
});
}
const paddingSize = padding(node) * k || 0;
// Padding is implemented by adding it to the children's radii, pack,
// then returning the radii to their original value.
if (paddingSize) {
children.forEach((child) => (child.r += paddingSize));
}
packSiblings(children);
const enclosingRadius = packEnclose(children).r;
if (paddingSize) {
children.forEach((child) => (child.r -= paddingSize));
}
node.r = enclosingRadius + paddingSize;
};
const packGrid = (circles) => {
const rows = toRows(circles);
placeRows(rows);
// Recenter everything over the origin
var enclosingCircle = packEnclose(circles);
forEach((c) => {
c.x -= enclosingCircle.x;
c.y -= enclosingCircle.y
}, circles);
};
export const svgEncloseRule = ({ d, i, screenCoordinates }) => {
const circle = packEnclose(
screenCoordinates.map(p => ({ x: p[0], y: p[1], r: 2 }))
)
return circleEnclosure({ d, i, circle })
}
export const svgEncloseRule = ({
d,
i,
projectedNodes,
nodeIDAccessor,
nodeSizeAccessor
}) => {
const selectedNodes = projectedNodes.filter(
p => d.ids.indexOf(nodeIDAccessor(p)) !== -1
)
if (selectedNodes.length === 0) {
return null
}
const circle = packEnclose(
selectedNodes.map(p => ({ x: p.x, y: p.y, r: nodeSizeAccessor(p) }))
)
return circleEnclosure({ circle, d, i })
}
export const svgEncloseAnnotation = ({ screenCoordinates, d, i }) => {
const circle = packEnclose(
screenCoordinates.map(p => ({ x: p[0], y: p[1], r: 2 }))
)
return circleEnclosure({ d, circle, i })
}