Add simple tree graph mode #4
@ -137,8 +137,8 @@ export function SimpleFamilyTree(p: {
|
|||||||
function NodeArea(p: {
|
function NodeArea(p: {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
parentLinkDestX?: number;
|
childrenLinkDestX?: number;
|
||||||
parentLinkDestY?: number;
|
childrenLinkDestY?: number;
|
||||||
node: SimpleTreeNode;
|
node: SimpleTreeNode;
|
||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
const parent_x_offset =
|
const parent_x_offset =
|
||||||
@ -169,7 +169,10 @@ function NodeArea(p: {
|
|||||||
|
|
||||||
let middleParentFaceY = p.y + Math.floor(FACE_HEIGHT / 2);
|
let middleParentFaceY = p.y + Math.floor(FACE_HEIGHT / 2);
|
||||||
|
|
||||||
// Compute point for link between children and parent
|
// Compute points for link between children and parent
|
||||||
|
let parentLinkX =
|
||||||
|
parent_x_offset + Math.floor(memberCardWidth(p.node.member) / 2);
|
||||||
|
let parentLinkY = p.y;
|
||||||
|
|
||||||
let childrenLinkX: number;
|
let childrenLinkX: number;
|
||||||
let childrenLinkY: number;
|
let childrenLinkY: number;
|
||||||
@ -185,6 +188,18 @@ function NodeArea(p: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{/* Parent link */}
|
||||||
|
{p.childrenLinkDestX && (
|
||||||
|
<path
|
||||||
|
className="link"
|
||||||
|
fill="none"
|
||||||
|
stroke="#000"
|
||||||
|
d={`M${p.childrenLinkDestX} ${p.childrenLinkDestY} V ${
|
||||||
|
parentLinkY - Math.floor(LEVEL_SPACING / 2)
|
||||||
|
} H${parentLinkX} V${parentLinkY}`}
|
||||||
|
></path>
|
||||||
|
)}
|
||||||
|
|
||||||
<MemberCard x={parent_x_offset} y={p.y} member={p.node.member} />
|
<MemberCard x={parent_x_offset} y={p.y} member={p.node.member} />
|
||||||
|
|
||||||
{p.node.spouse && (
|
{p.node.spouse && (
|
||||||
@ -210,6 +225,8 @@ function NodeArea(p: {
|
|||||||
<NodeArea
|
<NodeArea
|
||||||
x={downXOffset}
|
x={downXOffset}
|
||||||
y={p.y + CARD_HEIGHT + LEVEL_SPACING}
|
y={p.y + CARD_HEIGHT + LEVEL_SPACING}
|
||||||
|
childrenLinkDestX={childrenLinkX}
|
||||||
|
childrenLinkDestY={childrenLinkY}
|
||||||
node={n}
|
node={n}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -217,7 +234,8 @@ function NodeArea(p: {
|
|||||||
return el;
|
return el;
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{/*<circle cx={childrenLinkX} cy={childrenLinkY} r="2" fill="red" />*/}
|
{/*<circle cx={childrenLinkX} cy={childrenLinkY} r="2" fill="red" />
|
||||||
|
<circle cx={parentLinkX} cy={parentLinkY} r="2" fill="green" />*/}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user