Adjust settings

This commit is contained in:
Pierre HUBERT 2023-08-25 19:15:50 +02:00
parent e1bc10e299
commit b3a19831a4

View File

@ -77,8 +77,9 @@ export function ComplexFamilyTree(p: {
}; };
const exportPDF = async () => { const exportPDF = async () => {
const docWidth = treeWidth(p.tree) * 60; const docWidth = treeWidth(p.tree) * 65;
const docHeight = treeHeight(p.tree) * 41; const docHeight = treeHeight(p.tree) * 60;
console.info(`Tree w=${treeWidth(p.tree)} h=${treeHeight(p.tree)}`);
const doc = new jsPDF({ const doc = new jsPDF({
orientation: "l", orientation: "l",
@ -194,7 +195,8 @@ function treeWidth(node: FamilyTreeNode): number {
} }
function treeWidthRecurse(node: FamilyTreeNode, vals: number[], level: number) { function treeWidthRecurse(node: FamilyTreeNode, vals: number[], level: number) {
vals[level] += 1 + (node.couples?.length ?? 0) + (node.down ? 1 : 0); vals[level] +=
1 + (node.couples?.length ?? 0) + ((node.down?.length ?? 0) > 0 ? 1 : 0);
node.down?.forEach((n) => treeWidthRecurse(n, vals, level + 1)); node.down?.forEach((n) => treeWidthRecurse(n, vals, level + 1));