Fix parent-child connection lines and PED export label
Fixes: - Connection lines now start directly from the spouse line (parentY) instead of below the parent symbols (parentY + halfSymbol), ensuring lines connect properly without gaps - PED export now uses metadata.label instead of internal ID, so user- defined labels are preserved in exported files. Parent references (fatherId, motherId) also use the label mapping for consistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,12 @@ export class PedWriter {
|
||||
write(pedigree: Pedigree): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
// Build ID to label mapping (use label if available, otherwise use ID)
|
||||
const idToLabel = new Map<string, string>();
|
||||
for (const [id, person] of pedigree.persons) {
|
||||
idToLabel.set(id, person.metadata.label || id);
|
||||
}
|
||||
|
||||
// Add header comment
|
||||
lines.push(`# Pedigree: ${pedigree.familyId}`);
|
||||
lines.push(`# Generated: ${new Date().toISOString()}`);
|
||||
@@ -28,7 +34,7 @@ export class PedWriter {
|
||||
const sortedPersons = this.sortPersonsByGeneration(pedigree);
|
||||
|
||||
for (const person of sortedPersons) {
|
||||
const line = this.formatPersonLine(person);
|
||||
const line = this.formatPersonLine(person, idToLabel);
|
||||
lines.push(line);
|
||||
}
|
||||
|
||||
@@ -38,12 +44,16 @@ export class PedWriter {
|
||||
/**
|
||||
* Format a single person as a PED line
|
||||
*/
|
||||
private formatPersonLine(person: Person): string {
|
||||
private formatPersonLine(person: Person, idToLabel: Map<string, string>): string {
|
||||
const individualId = idToLabel.get(person.id) || person.id;
|
||||
const paternalId = person.fatherId ? (idToLabel.get(person.fatherId) || person.fatherId) : '0';
|
||||
const maternalId = person.motherId ? (idToLabel.get(person.motherId) || person.motherId) : '0';
|
||||
|
||||
const fields = [
|
||||
person.familyId,
|
||||
person.id,
|
||||
person.fatherId ?? '0',
|
||||
person.motherId ?? '0',
|
||||
individualId,
|
||||
paternalId,
|
||||
maternalId,
|
||||
this.formatSex(person.sex),
|
||||
this.formatPhenotype(person.phenotypes[0] ?? Phenotype.Unknown),
|
||||
];
|
||||
|
||||
@@ -137,11 +137,11 @@ export class ConnectionRenderer {
|
||||
}
|
||||
|
||||
const childY = children[0].y;
|
||||
const midY = parentY + halfSymbol + dropHeight;
|
||||
const midY = parentY + dropHeight;
|
||||
|
||||
// Vertical line from parent connection point
|
||||
// Vertical line from parent connection point (starts at spouse line level)
|
||||
paths.push({
|
||||
d: `M ${parentX} ${parentY + halfSymbol} L ${parentX} ${midY}`,
|
||||
d: `M ${parentX} ${parentY} L ${parentX} ${midY}`,
|
||||
className: 'connection-parent-child',
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user