Schematex

Genogram

Multi-generation family trees following the McGoldrick standard. Gender-specific shapes, medical condition fills, emotional relationship lines, index-person markers. Used in family therapy, social work, and clinical medicine.

Genogram: The Potter Family Genogram diagram with 10 individuals across 3 generations The Potter Family Fleamont (1909-1979) 70 Euphemia (1920-1979) 59 Mr_evans (1925) Mrs_evans (1928) James (1960-1981) 21 Lily (1960-1981) 21 Vernon (1951) Petunia (1958) Harry (1980) Dudley (1980) Fleamont (1909–1979) Euphemia (1920–1979) Mr_evans (b. 1925) Mrs_evans (b. 1928) James (1960–1981) Lily (1960–1981) Vernon (b. 1951) Petunia (b. 1958) Harry (b. 1980) Dudley (b. 1980) m. 1978

McGoldrick et al. (2020) 符号系统 + GenoPro emotional taxonomy + Bennett 2022 gender inclusivity + 临床医疗条件系统 + Cultural Heritage genogram 支持。

Primary References:

  • McGoldrick, M., Gerson, R., & Petry, S. (2020). Genograms: Assessment and Treatment. 4th ed.
  • Bennett, R.L. et al. (2022). Standardized human pedigree nomenclature: Update and assessment of the recommendations of the National Society of Genetic Counselors. J Genet Couns.
  • Hardy, K.V. & Laszloffy, T.A. (1995). The cultural genogram: Key to training culturally competent family therapists. J Marital Fam Ther, 21(3), 227-237.
  • GenoPro symbol reference: https://genopro.com/genogram/
  • GenogramAI symbol catalog (~150 symbols): https://genogramai.com

1. Individual Symbols

1.1 Core Shapes

SymbolShapeSVG Element含义
Square (40×40)<rect>Male
Circle (r=20)<circle>Female
Diamond (40×40)<polygon>Unknown sex / Nonbinary (Bennett 2022)
Triangle (small, 20×20)<polygon>Pregnancy (current)
Concentric shapeDouble outline (gap=3px)Two shapes, inner + outerIndex Person (IP) / Identified Patient

1.2 Status Modifiers

StatusVisualSVG Implementation
DeceasedX through shape, corner to cornerTwo <line> elements crossing shape
Stillborn50% size shape + SB labelScaled shape with text
MiscarriageSmall triangle (△, 12×12)<polygon> small
Spontaneous abortionSmall × (12×12)Two short <line> elements
Induced abortionSmall × with horizontal line through<line> elements + cross bar
PregnancyDashed outlinestroke-dasharray="4,3" on shape

1.3 Bennett 2022 Gender/Sex Inclusivity Update

Bennett 2022 引入了 sex 与 gender 分离的符号系统,Schematex 必须支持:

Notation含义Visual
AMABAssigned Male at BirthSquare (传统 male symbol)
AFABAssigned Female at BirthCircle (传统 female symbol)
UAABUnknown/Ambiguous at Birth / IntersexDiamond
NonbinaryGender identity = nonbinaryDiamond + optional gender label
TransgenderGender ≠ assigned sexShape = assigned sex, label indicates gender identity

DSL 表示:

alex [nonbinary, 1995]           # → diamond
sam [male, transgender, 1988]    # → square (AMAB) + transgender marker
jordan [intersex, 1990]          # → diamond (UAAB)

实现规则:

  • sex property 控制 shape(male→□, female→○, unknown/nonbinary/intersex→◇)
  • transgender property 添加一个小三角标记在 shape 角落
  • gender property 可选,用于 label 显示

1.4 Multiple Births

TypeVisualDSL
Identical twinsV-shape: two child lines meet at single point on sibship line[twin-identical]
Fraternal twinsInverted-V with horizontal bar connecting at top[twin-fraternal]
Triplets+Same pattern, 3+ lines from single point or bar[triplet-identical] / [triplet-fraternal]

1.5 SVG Implementation Notes

  • All shapes: stroke-width: 2, fill: white (default), stroke: #333
  • CSS classes: schematex-node, schematex-male, schematex-female, schematex-unknown, schematex-nonbinary
  • Deceased overlay: class="schematex-deceased-marker"
  • Index person: outer shape stroke-width: 1, inner shape stroke-width: 2, gap 3px
  • Data attributes: data-individual-id, data-sex, data-status, data-generation

2. Medical/Psychological Condition System

2.1 Condition Display: Quadrant Fill System

Conditions 通过填充 individual shape 的不同区域来表示。最多同时显示 4 个条件(quadrant system),超过 4 个时切换到 radial pie display 或 legend 系统。

Fill PositionQuadrantSVG Implementation
Full fill整个 shapefill: {color}
Top-left quarter左上 1/4<clipPath> top-left quadrant
Top-right quarter右上 1/4<clipPath> top-right quadrant
Bottom-left quarter左下 1/4<clipPath> bottom-left quadrant
Bottom-right quarter右下 1/4<clipPath> bottom-right quadrant
Half-left左半<clipPath> left half
Half-right右半<clipPath> right half
Half-top上半<clipPath> top half
Half-bottom下半<clipPath> bottom half
Striped/hatched斜线填充<pattern> diagonal lines
Dotted点状填充<pattern> dots

多条件叠加规则:

  1. 1 条件 → full fill 或 half fill
  2. 2 条件 → left half + right half
  3. 3 条件 → top-left + top-right + bottom half
  4. 4 条件 → 四个 quadrant
  5. 5+ 条件 → radial pie(等分扇形)or numbered legend
  6. Carrier (无症状) → striped/hatched pattern,不占 quadrant

2.2 Standard Medical Condition Categories (22 Categories)

基于 GenogramAI + 临床实践的标准颜色编码系统。每个 category 有推荐颜色,用户可自定义。

CategoryDefault ColorHex常见疾病
CardiovascularRed#E53935Heart disease, hypertension, stroke, CHF
CancerDark Blue#1E88E5All malignancies (可按类型细分)
DiabetesOrange#FB8C00Type 1, Type 2, gestational
Mental Health (General)Purple#8E24AASchizophrenia, psychosis, other
DepressionIndigo#5C6BC0Major depressive disorder, dysthymia
AnxietyTeal#26A69AGAD, panic disorder, phobias, OCD
BipolarViolet#AB47BCBipolar I, Bipolar II
PTSDDark Teal#00897BPost-traumatic stress disorder
Substance Abuse (Alcohol)Amber#FFB300Alcohol use disorder
Substance Abuse (Drugs)Deep Orange#F4511EDrug use disorder (opioids, stimulants, etc.)
Substance Abuse (Tobacco)Brown#795548Nicotine dependence
NeurologicalGray-Blue#546E7AAlzheimer's, Parkinson's, epilepsy, MS
RespiratoryLight Blue#42A5F5Asthma, COPD, cystic fibrosis
AutoimmunePink#EC407ALupus, rheumatoid arthritis, Crohn's
Genetic/ChromosomalDark Green#2E7D32Down syndrome, sickle cell, Huntington's
ReproductiveRose#F48FB1Infertility, PCOS, endometriosis
Eating DisordersLight Purple#CE93D8Anorexia, bulimia, BED
Learning/DevelopmentalLime#9CCC65ADHD, autism spectrum, dyslexia
Kidney/UrologicalOlive#827717CKD, kidney stones
Liver/GIYellow-Green#C0CA33Hepatitis, cirrhosis, IBD
ObesityDark Amber#FF8F00BMI ≥ 30
Other/CustomGray#757575Any unlisted condition

2.3 Condition SVG Defs

每个使用的 condition 需要在 <defs> 中定义对应的 <clipPath> 和可选 <pattern>

<defs>
  <!-- Quadrant clip paths for squares (40×40) -->
  <clipPath id="quad-tl-rect"><rect x="0" y="0" width="20" height="20"/></clipPath>
  <clipPath id="quad-tr-rect"><rect x="20" y="0" width="20" height="20"/></clipPath>
  <clipPath id="quad-bl-rect"><rect x="0" y="20" width="20" height="20"/></clipPath>
  <clipPath id="quad-br-rect"><rect x="20" y="20" width="20" height="20"/></clipPath>
  <clipPath id="half-left-rect"><rect x="0" y="0" width="20" height="40"/></clipPath>
  <clipPath id="half-right-rect"><rect x="20" y="0" width="20" height="40"/></clipPath>
  <clipPath id="half-top-rect"><rect x="0" y="0" width="40" height="20"/></clipPath>
  <clipPath id="half-bottom-rect"><rect x="0" y="20" width="40" height="20"/></clipPath>

  <!-- Quadrant clip paths for circles (r=20) -->
  <!-- Use rect clips centered at circle center, intersected with circle -->

  <!-- Carrier pattern (diagonal stripes) -->
  <pattern id="carrier-stripe" patternUnits="userSpaceOnUse" width="6" height="6">
    <path d="M-1,1 l2,-2 M0,6 l6,-6 M5,7 l2,-2" stroke="#333" stroke-width="1"/>
  </pattern>

  <!-- Dotted pattern -->
  <pattern id="dotted" patternUnits="userSpaceOnUse" width="6" height="6">
    <circle cx="3" cy="3" r="1" fill="#333"/>
  </pattern>
</defs>

2.4 DSL Syntax for Conditions

# 单条件
father [male, 1945, conditions: heart-disease(full, #E53935)]

# 多条件(自动分配 quadrant)
mother [female, 1948, conditions: diabetes + cancer + anxiety]

# 指定 fill position + color
uncle [male, 1950, conditions: heart-disease(half-left, #E53935) + diabetes(half-right, #FB8C00)]

# Carrier(无症状)
son [male, 1975, conditions: diabetes(carrier)]

# 使用 category shorthand
daughter [female, 1978, conditions: cardiovascular + mental-health]

解析规则:

  • 没有指定 fill position 时,自动按条件数量分配(见 2.1 叠加规则)
  • 没有指定 color 时,使用 category 默认颜色
  • carrier fill → striped pattern
  • Category shorthand(如 cardiovascular)映射到默认颜色
  • 自定义条件名(不在标准 category 中)使用 gray 默认色

2B. Cultural/Heritage Genogram (Ethnicity Color System)

Cultural genogram(Hardy & Laszloffy, 1995)使用与医疗 genogram 相同的 shape + fill 机制,但颜色含义不同——表示种族/文化/民族背景而非医疗条件。

这是社工领域的重要变体,用于多元文化评估。

2B.1 Heritage Color Coding

每种文化背景对应一个颜色。用户通过 legend 自定义映射(没有固定标准,因文化背景因地而异):

genogram "Anna Maria's Heritage"
  legend: colombian = "Colombian" (#9C27B0)
  legend: dominican = "Dominican Republic" (#FFEB3B)
  legend: french = "French" (#1565C0)
  legend: greek = "Greek" (#80DEEA)
  legend: irish = "Irish" (#4CAF50)
  legend: italian = "Italian" (#E91E63)
  legend: puerto-rican = "Puerto Rican" (#FF9800)

2B.2 Mixed Heritage Display

当一个人有多种文化背景时,使用与医疗条件相同的 quadrant/half fill 系统

# 单一背景 → full fill
jose [male, heritage: colombian]

# 双重背景 → half-left + half-right
anna-maria [female, heritage: puerto-rican + italian]

# 三重背景 → quadrant fill
child [male, heritage: irish + italian + french]

渲染机制完全复用 Section 2.1 的 quadrant fill system,只是颜色来源不同(heritage legend vs. medical category)。

2B.3 Heritage vs. Medical Conditions

一个 genogram 可以同时展示 heritage 和 medical conditions,但不能在同一个 shape 上混用(会视觉冲突)。解决方案:

  1. 分层展示: heritage 用 shape fill color,medical conditions 用 shape border 上的小标记(dots/icons)
  2. 模式切换: DSL header 声明 genogram [mode: heritage]genogram [mode: medical],渲染器据此决定 fill 含义
  3. 推荐: 默认 mode=medical(最常见),heritage mode 需显式声明

2B.4 DSL Syntax

genogram "Heritage Example" [mode: heritage]
  legend: colombian = "Colombian" (#9C27B0)
  legend: irish = "Irish" (#4CAF50)
  
  father [male, 1960, heritage: colombian]
  mother [female, 1962, heritage: irish]
  father -- mother
    child [female, 1990, heritage: colombian + irish]

2C. Label & Annotation System

基于真实 genogram 使用场景(临床评估、教学案例、案例展示),individual nodes 需要丰富的标注系统。

2C.1 In-Shape Display

Age number 显示在 shape 内部(常见于临床展示型 genogram):

Display位置DSL含义
Age numberShape 中心[age: 57] or auto-calculated from birth year当前年龄或去世时年龄
InitialsShape 中心[initials: "JG"]名字缩写

实现:

  • Age/initials 作为 <text> 渲染在 shape 中心
  • Font: bold, 12-14px, class="schematex-in-shape-text"
  • 如果同时有 condition fill,text 颜色自动调整为白色(深色 fill 时)或黑色(浅色/无 fill 时)
  • DSL 中 age 可以省略——如果有 birth year,renderer 可自动计算

2C.2 Below-Shape Labels

标准 label 位置(shape 下方),支持多行:

Line内容示例
Line 1Name (required)"Ross"
Line 2Birth/death years"(1966)" or "(1930-2020)"
Line 3+Annotations"Paleontologist", "Smoking", "Diabetes"

2C.3 Rich Annotations

Individual 可以附加多行文字注释,用于临床评估记录:

ross [male, 1966, label: "Ross"]
  @occupation: "Paleontologist, College Professor"
  @traits: "Geeky, Quirky"  
  @notes: "Golden Child/Favorite"

或 inline 简化语法:

ross [male, 1966, occupation: "Professor", notes: "Golden Child"]

渲染:

  • Annotations 显示在 name + year 下方
  • Font: italic, 10px, class="schematex-annotation"
  • 最多显示 3 行 annotation,超出部分 truncate + tooltip
  • 可通过 render config 控制是否显示 annotations

2C.4 Relationship Labels on Lines

Couple 和 emotional relationship lines 可以附加文字标签:

jack -- judy [label: "Married 35 yrs"]
ross -close- monica [label: "Competitive"]
ross -hostile- rachel [label: "On and off"]

渲染:

  • Label 显示在 line 中点上方(couple lines)或沿着 line(emotional lines)
  • Font: 10px, class="schematex-edge-label"
  • 背景色:white with slight opacity,避免与 line 混淆

2D. In-Law & Extended Family Notation

2D.1 In-Law Relationships

In-law(姻亲)关系通过 marriage 自动推导,不需要单独的 relationship type。但在 label 显示时需要标注:

Relationship如何标注说明
Father-in-law / Mother-in-law通过 spouse 的 parent 自动推导不需要额外 DSL
Brother-in-law / Sister-in-law通过 spouse 的 sibling 自动推导不需要额外 DSL
Son-in-law / Daughter-in-law通过 child 的 spouse 自动推导不需要额外 DSL

显示可选: Renderer 可以在 label 中显示 in-law relationship(如 "Brother-in-law"),通过 render config showInLawLabels: true 控制。

2D.2 Non-Family Members in Genogram

有些 genogram 包含非家庭成员(如 therapist, friend, mentor),这些人的 shape 通常用虚线边框表示:

therapist [other, label: "Dr. Smith", external: true]
ross -close- therapist
  • external: true → dashed border on shape
  • 不参与 generation alignment(浮动定位在相关 individual 附近)

2E. Legend Box

复杂 genogram 必须包含 legend box 解释颜色/符号含义。

2E.1 Auto-Generated Legend

Renderer 自动生成 legend,包含图中实际使用的:

  • Condition categories + 对应颜色
  • Heritage colors (if heritage mode)
  • Emotional relationship line styles
  • Special symbols (adopted, foster, deceased, etc.)

2E.2 Legend Positioning

Position何时使用
Bottom-right (default)大多数情况
Right side图表较宽时
Bottom center图表较高时
External (separate SVG group)嵌入到网页时可单独定位

2E.3 DSL

genogram "Family Study" [legend: bottom-right]
  # ... individuals and relationships ...

Legend 内容自动从图中使用的 conditions/heritage/relationships 推导,不需要手动指定每一项。但 legend: 定义(见 2B.1)可覆盖自动推导的颜色/标签。


3. Relationship Lines

3.1 Couple/Partnership Relationships

RelationshipLine StyleDSL SyntaxSVG
MarriageSolid horizontal lineA -- B<line> stroke-width: 2
Cohabitation/LTRDashed lineA ~ Bstroke-dasharray="6,4"
EngagementSolid + small diamond midpointA -o- Bline + small diamond marker
SeparationSolid + single slashA -/- Bline + one diagonal slash
DivorceSolid + double slashA -x- Bline + two diagonal slashes
ConsanguinityDouble horizontal lineA == BTwo parallel lines, gap 4px
RemarriageNew marriage line from same personSecond A -- CAdditional horizontal line
Same-sex marriageSame as marriageA -- B (both same sex)Same rendering, positioning by age
Domestic partnershipDashed + DP labelA ~dp~ Bstroke-dasharray + text label

3.2 Emotional Relationship Types (GenoPro 34-Type Taxonomy)

这是 genogram 临床使用中最重要的扩展。GenoPro 定义了 34 种 emotional relationship types,分为 7 大类:

Category 1: Positive/Close Relationships

TypeLine StyleDSL含义
HarmonySingle green solid lineA -harmony- B和谐关系
CloseTwo parallel green linesA -close- B亲密
Best friendsThree parallel green linesA -bestfriends- B最好的朋友
LoveHeart symbol on lineA -love- B
In loveDouble heart on lineA -inlove- B热恋
FriendshipSingle blue lineA -friendship- B友谊

Category 2: Negative/Hostile Relationships

TypeLine StyleDSL含义
HostileZigzag red lineA -hostile- B敌对
ConflictZigzag line + hash marksA -conflict- B冲突
EnmityThick zigzag red lineA -enmity- B仇恨
Distant-hostileDotted zigzag lineA -distant-hostile- B疏远+敌对
CutoffBroken line with gapA -cutoff- B断绝关系

Category 3: Ambivalent/Complex Relationships

TypeLine StyleDSL含义
Close-hostileTwo parallel + zigzagA -close-hostile- B亲密但敌对
FusedThree parallel lines (intense)A -fused- B融合(over-involved)
Fused-hostileThree parallel + zigzagA -fused-hostile- B融合+敌对

Category 4: Distance Relationships

TypeLine StyleDSL含义
DistantDotted thin lineA -distant- B疏远
Plain/NormalSingle solid line (default)A -normal- B普通关系
Never metNo line (gap symbol)A -nevermet- B从未见面

Category 5: Abuse Relationships

TypeLine StyleDSL含义
Abuse (general)Arrow + red zigzagA -abuse-> B虐待(方向性)
Physical abuseArrow + thick red zigzagA -physical-abuse-> B身体虐待
Emotional abuseArrow + wavy red lineA -emotional-abuse-> B情感虐待
Sexual abuseArrow + red zigzag + dotA -sexual-abuse-> B性虐待
NeglectArrow + thin dotted redA -neglect-> B忽视

注意: 虐待关系有方向性-> 表示 A 对 B 施虐)。

Category 6: Control/Power Relationships

TypeLine StyleDSL含义
ManipulativeArrow + curved lineA -manipulative-> B操控
ControllingArrow + thick line + barA -controlling-> B控制
JealousArrow + green zigzagA -jealous-> B嫉妒

Category 7: Special Relationships

TypeLine StyleDSL含义
Focused onArrow + magnifying symbolA -focused-> B关注(正面)
Focused on negativelyArrow + negative magnifyingA -focused-neg-> B负面关注
DistrustDotted line + XA -distrust- B不信任
Fan/AdmirerArrow + starA -admirer-> B崇拜/粉丝
LimerenceArrow + heart + questionA -limerence-> B单恋/迷恋

3.3 Emotional Relationship SVG Implementation

Line rendering priority:

  1. Base line shape: straight / zigzag / wavy / dotted / dashed
  2. Color coding: green (positive), red (negative/abuse), blue (neutral), orange (control)
  3. Multiplicity: 1 line (normal), 2 lines (close), 3 lines (fused/best friends)
  4. Directional markers: arrowhead for abuse/control/focused relationships
  5. Special symbols: heart, X, star (rendered as small SVG markers at line midpoint)

SVG markers in <defs>

<defs>
  <marker id="arrow" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto">
    <path d="M 0 0 L 10 5 L 0 10 z" fill="#333"/>
  </marker>
  <marker id="heart" viewBox="0 0 12 12" refX="6" refY="6" markerWidth="8" markerHeight="8">
    <path d="M6,10 C2,6 0,4 2,2 C4,0 6,2 6,4 C6,2 8,0 10,2 C12,4 10,6 6,10z" fill="#E53935"/>
  </marker>
</defs>

Zigzag path generation(for hostile/conflict):

M x1,y1 L x1+10,y1-5 L x1+20,y1+5 L x1+30,y1-5 ... L x2,y2

3.4 Parent-Child Relationships

RelationshipLine StyleDSL Property含义
Biological childSolid vertical line(default)亲生
Adopted childDashed line + brackets[adopted]收养
Foster childDotted vertical line[foster]寄养
Identical twinsLines meet at single point (V)[twin-identical]同卵双胞胎
Fraternal twinsLines connect with bar[twin-fraternal]异卵双胞胎
Triplets+3+ lines from single point/bar[triplet-identical]三胞胎+
SurrogacyDotted line + S label[surrogate]代孕
Donor gameteDotted line + D label[donor]供体配子
Step-childStep-shaped line (two right angles)[step]继子女

3.5 Modern Family Structures

Schematex 必须支持现代非传统家庭结构:

Structure处理方式
Same-sex parents两个同性 partner,standard couple line,children 连接方式相同
Single parent by choice只有一个 parent node,直接 vertical line to children
Donor conceptionDotted line from donor node(可选显示/隐藏 donor)
SurrogacySurrogate 用 dotted line 连接到 child,biological parents 用 solid line
Co-parenting (non-couple)Two individuals connected to children but no couple line between them
Blended familyStep-children connections + multiple marriage lines
Polyamorous familyMultiple concurrent couple lines from same individual (no divorce markers)

Children connection structure (standard):

Father ────── Mother       (couple line)

       ├──── Child 1        (sibship line + drop lines)
       ├──── Child 2
       └──── Child 3

4. Layout Rules

4.1 Generation Alignment

  • 同代人物必须在同一 Y 坐标——最重要的布局约束
  • Generation 0(最年长一代)在最上方
  • Y 坐标向下递增(SVG 坐标系)
  • Generation 间距:默认 120px

4.2 Couple Positioning

  • Male left, female right(McGoldrick 标准硬规则)
  • 同性伴侣:按年龄排(年长左,年轻右)
  • Nonbinary 伴侣:按 DSL 中出现顺序(第一个左)
  • Couple line 水平,连接两人 shape 中心高度

4.3 Children Ordering

  • 子女从左到右按出生年份排序(年长 → 年幼)
  • 子女组居中对齐在 couple line 下方
  • Sibship line 在 couple line 正下方

4.4 Multiple Marriages

  • 按时间顺序从左到右排列
  • 第一任配偶最内侧,后续向外
  • 每段婚姻子女挂在各自 couple line 下

4.5 Edge Crossing Minimization

  • Barycenter method 启发式
  • 优先级:parent-child 不交叉 > couple 不交叉 > emotional relationship 不交叉

4.6 Spacing Rules

ParameterDefault含义
Node width40pxIndividual shape width
Node height40pxIndividual shape height
Sibling spacing60pxHorizontal between siblings
Family unit spacing80pxHorizontal between family units
Generation spacing120pxVertical between generations
Couple line length60pxBetween partners
Drop line length40pxCouple to sibship line
Emotional line offset20pxOffset from structural lines (avoid overlap)

4.7 Emotional Relationship Line Routing

  • Emotional relationship lines 渲染在 structural lines(couple/parent-child)之上
  • 如果 A 和 B 在不同 generation,line 绕过中间 nodes(避免穿过 shapes)
  • 同 generation 内的 emotional lines 画在 nodes 下方(curved path)
  • 不同 generation 的 emotional lines 画在右侧(避开 parent-child 区域)

5. DSL Grammar (Genogram — Expanded)

document       = header? legend_def* statement*
header         = "genogram" quoted_string? header_props? NEWLINE
header_props   = "[" header_prop ("," header_prop)* "]"
header_prop    = "mode:" MODE | "legend:" POSITION
MODE           = "medical" | "heritage"    # default: medical
POSITION       = "bottom-right" | "right" | "bottom-center" | "none"

legend_def     = "legend:" IDENTIFIER "=" quoted_string ( "(" color ")" )? NEWLINE

statement      = comment | individual_def | relationship_def
               | emotional_rel_def | annotation_def

comment        = "#" [^\n]* NEWLINE

individual_def = ID properties? NEWLINE
properties     = "[" property ("," property)* "]"
property       = sex_prop | gender_prop | status_prop | year_prop
               | condition_prop | heritage_prop | child_prop | kv_prop

sex_prop       = "male" | "female" | "unknown" | "nonbinary" | "intersex"
gender_prop    = "transgender"
status_prop    = "deceased" | "stillborn" | "miscarriage" | "abortion" | "pregnancy"
year_prop      = /[0-9]{4}/
condition_prop = "conditions:" condition ("+" condition)*
condition      = IDENTIFIER ( "(" fill_spec ")" )?
fill_spec      = (fill_position ("," color)?) | "carrier"
fill_position  = "full" | "half-left" | "half-right" | "half-top" | "half-bottom"
               | "quad-tl" | "quad-tr" | "quad-bl" | "quad-br"
heritage_prop  = "heritage:" IDENTIFIER ("+" IDENTIFIER)*
color          = "#" HEX{6} | NAMED_COLOR
child_prop     = "adopted" | "foster" | "surrogate" | "donor" | "step"
               | "twin-identical" | "twin-fraternal"
               | "triplet-identical" | "triplet-fraternal"
kv_prop        = IDENTIFIER ":" VALUE

annotation_def = INDENT "@" IDENTIFIER ":" quoted_string NEWLINE  # follows individual_def

relationship_def       = couple_rel | couple_with_children
couple_rel             = ID couple_op ID rel_label? NEWLINE
couple_with_children   = ID couple_op ID rel_label? NEWLINE INDENT child+ DEDENT
couple_op              = "--" | "-x-" | "-/-" | "~" | "==" | "-o-" | "~dp~"
rel_label              = "[" "label:" quoted_string "]"
child                  = individual_def

emotional_rel_def      = ID emotional_op ID rel_label? NEWLINE
emotional_op           = "-" EMOTIONAL_TYPE "-" ID
                       | "-" EMOTIONAL_TYPE "->" ID    # directional (abuse, control, focused)

EMOTIONAL_TYPE = "harmony" | "close" | "bestfriends" | "love" | "inlove"
               | "friendship" | "hostile" | "conflict" | "enmity"
               | "distant-hostile" | "cutoff" | "close-hostile"
               | "fused" | "fused-hostile" | "distant" | "normal" | "nevermet"
               | "abuse" | "physical-abuse" | "emotional-abuse"
               | "sexual-abuse" | "neglect"
               | "manipulative" | "controlling" | "jealous"
               | "focused" | "focused-neg" | "distrust"
               | "admirer" | "limerence"

ID             = /[a-zA-Z][a-zA-Z0-9_-]*/
IDENTIFIER     = /[a-zA-Z][a-zA-Z0-9_-]*/
VALUE          = /[^\],\n]+/
quoted_string  = '"' /[^"]*/ '"'
INDENT         = increase in leading whitespace (2+ spaces)
DEDENT         = decrease in leading whitespace
NEWLINE        = /\n/

Parser 注意事项:

  • 缩进敏感(类似 Python/YAML),用于表示 parent-child 关系
  • # 开头为行注释
  • Properties 中逗号分隔,顺序无关
  • ID 大小写不敏感(匹配时),但显示时保留原始大小写
  • 同一 ID 可出现多次:第一次定义属性,后续为引用
  • 空行忽略
  • Emotional relationship 定义独立于 couple/parent-child 定义
  • 宽容解析:多余空格、缺少逗号等尽量容错,给出友好错误信息

6. Test Cases

Case 1: Nuclear Family (Basic)

genogram
  john [male, 1950]
  mary [female, 1955]
  john -- mary
    alice [female, 1980]
    bob [male, 1983]

验证:john 在 mary 左边,alice 在 bob 左边(年长),generation 0 / generation 1。

Case 2: Three Generations

genogram "Smith Family"
  grandpa [male, 1930, deceased]
  grandma [female, 1932]
  grandpa -- grandma
    dad [male, 1955]
    aunt [female, 1958]
  dad -- mom [female, 1957]
    me [male, 1985]
    sister [female, 1988]

Case 3: Divorce + Remarriage

genogram
  tom [male, 1950]
  jane [female, 1952]
  tom -x- jane
    child1 [male, 1975]
  tom -- susan [female, 1960]
    child2 [female, 1985]

验证:jane 和 susan 分别在 tom 不同侧,divorce 标记在 tom-jane 线上。

Case 4: Medical Conditions (Color-coded)

genogram
  father [male, 1945, conditions: heart-disease(half-left, #E53935) + diabetes(half-right, #FB8C00)]
  mother [female, 1948, conditions: depression(full, #5C6BC0)]
  father -- mother
    son [male, 1970, conditions: diabetes(carrier)]
    daughter [female, 1973, conditions: anxiety(full, #26A69A) + heart-disease(carrier)]

验证:father 有两色半填充,mother 全填充 indigo,son 有 striped pattern,daughter 有 teal fill + stripe。

Case 5: Single Individual

genogram
  solo [female, 1990]

验证:单人渲染不崩溃,居中显示。

Case 6: Childless Couple

genogram
  husband [male, 1960]
  wife [female, 1962]
  husband -- wife

验证:只有 couple line,无 children line。

Case 7: Emotional Relationships

genogram
  mom [female, 1955]
  dad [male, 1953]
  son [male, 1980]
  daughter [female, 1983]
  mom -- dad
    son
    daughter
  mom -close- daughter
  dad -hostile- son
  mom -fused- son
  dad -distant- daughter

验证:4 条 emotional relationship lines 叠加在 structural lines 上,各有正确的 line style 和 color。

Case 8: Modern Family (LGBTQ+ / Donor)

genogram "Modern Family"
  alex [female, 1985]
  sam [female, 1987]
  alex -- sam
    child [male, 2015, donor]
  donor-d [male, 1980]

验证:同性 couple(按年龄排列),child 有 donor marker,donor-d 可选显示。

Case 9: Abuse + Control Relationships

genogram
  father [male, 1950]
  mother [female, 1955]
  child [female, 1978]
  father -- mother
    child
  father -physical-abuse-> mother
  father -emotional-abuse-> child

验证:abuse lines 有方向箭头,red zigzag 样式,overlaid on structural connections。

Case 10: Nonbinary / Transgender

genogram
  parent1 [male, 1960]
  parent2 [female, 1962]
  child1 [nonbinary, 1990]
  child2 [male, transgender, 1992]
  parent1 -- parent2
    child1
    child2

验证:child1 renders as diamond,child2 renders as square + transgender marker。

Case 11: Cultural Heritage Genogram

genogram "Anna Maria's Heritage" [mode: heritage]
  legend: colombian = "Colombian" (#9C27B0)
  legend: dominican = "Dominican Republic" (#FFEB3B)
  legend: french = "French" (#1565C0)
  legend: irish = "Irish" (#4CAF50)
  legend: puerto-rican = "Puerto Rican" (#FF9800)

  jose [male, 1940, heritage: colombian]
  benita [female, 1942, heritage: dominican]
  jose -- benita
    felipa [female, 1965, heritage: colombian + dominican]
  patrick [male, 1938, heritage: irish]
  marie [female, 1940, heritage: french]
  patrick -- marie
    michael [male, 1966, heritage: irish + french]
  felipa -- michael
    anna-maria [female, 1990, heritage: colombian + dominican + irish + french]

验证:heritage mode 激活,legend box 显示 5 种颜色,anna-maria 的 shape 有 4-quadrant fill,每个 quadrant 颜色对应不同 heritage。

Case 12: Rich Annotations + In-Shape Age

genogram "Clinical Assessment"
  jack [male, 1968, age: 57, occupation: "Veteran, Businessman"]
    @traits: "Tone Deaf Dad"
    @medical: "Smoking, Diabetes"
  judy [female, 1970, age: 55, occupation: "Homemaker"]
    @notes: "Good Wife, Good Mother"
  jack -- judy [label: "Married 35 yrs"]
    ross [male, 1989, age: 36, occupation: "Professor"]
    monica [female, 1991, age: 34, occupation: "Chef"]
      @traits: "Hardworking, Type A, Neat Freak"
  jack -close- ross [label: "Favoritism"]
  judy -close- monica [label: "Favoritism"]
  ross -hostile- monica [label: "Competitive"]

验证:age number (57, 55, 36, 34) 显示在 shape 内部,annotations 显示在 name 下方,relationship labels 显示在 lines 上。

Case 13: Extended Family with In-Laws

genogram "Extended Family"
  # Paternal side
  gf1 [male, 1940]
  gm1 [female, 1942]
  gf1 -- gm1
    uncle1 [male, 1965]
    father [male, 1968]
  uncle1 -- aunt1 [female, 1967]
    cousin [male, 1992]

  # Maternal side
  gf2 [male, 1938]
  gm2 [female, 1940]
  gf2 -- gm2
    mother [female, 1970]
    uncle2 [male, 1972]
  uncle2 -- aunt2 [female, 1974]

  # Nuclear family
  father -- mother
    me [male, 1995]
    brother [male, 1997]
    sister [female, 2000]
  sister -- bro-in-law [male, 1998]
  brother -- sis-in-law [female, 1999]

验证:两个 grandparent couple 在 generation 0,parents + uncles/aunts 在 generation 1,me/siblings + in-laws 在 generation 2。


7. Implementation Priority

Phase 1 的 parser/layout/renderer 已经实现了基础功能(Cases 1-6)。以下是扩展优先级:

PriorityFeatureComplexity用户价值
P0 (Phase 1 ✅)Basic symbols + couple + parent-child + conditions (simple fills)DoneCore
P1Color-coded condition categories (22 categories)MediumHigh — 医疗专业用户核心需求
P1Emotional relationships (at least top 10 types)MediumHigh — 社工/治疗师核心需求
P1In-shape age/text displayLowHigh — 几乎所有临床 genogram 都有
P1Relationship labels on linesLowHigh — 临床 genogram 标配
P1Legend box auto-generationMediumHigh — 复杂 genogram 必须
P2Full 34 emotional relationship typesMediumMedium — 专业级 genogram
P2Bennett 2022 gender inclusivityLowMedium — 现代化必须
P2Abuse/control directional relationshipsMediumHigh — 临床评估核心
P2Modern family structures (donor, surrogate, step)MediumMedium — 现代家庭
P2Cultural Heritage genogram modeMediumMedium — 社工/多文化评估
P2Rich annotations (@occupation, @traits, @notes)MediumMedium — 临床文档化
P3Quadrant fill → radial pie for 5+ conditionsHighLow — edge case
P3Emotional line routing (avoid overlap)HighMedium — 视觉质量
P3External/non-family members (dashed border)LowLow — niche use case

On this page

1. Individual Symbols1.1 Core Shapes1.2 Status Modifiers1.3 Bennett 2022 Gender/Sex Inclusivity Update1.4 Multiple Births1.5 SVG Implementation Notes2. Medical/Psychological Condition System2.1 Condition Display: Quadrant Fill System2.2 Standard Medical Condition Categories (22 Categories)2.3 Condition SVG Defs2.4 DSL Syntax for Conditions2B. Cultural/Heritage Genogram (Ethnicity Color System)2B.1 Heritage Color Coding2B.2 Mixed Heritage Display2B.3 Heritage vs. Medical Conditions2B.4 DSL Syntax2C. Label & Annotation System2C.1 In-Shape Display2C.2 Below-Shape Labels2C.3 Rich Annotations2C.4 Relationship Labels on Lines2D. In-Law & Extended Family Notation2D.1 In-Law Relationships2D.2 Non-Family Members in Genogram2E. Legend Box2E.1 Auto-Generated Legend2E.2 Legend Positioning2E.3 DSL3. Relationship Lines3.1 Couple/Partnership Relationships3.2 Emotional Relationship Types (GenoPro 34-Type Taxonomy)Category 1: Positive/Close RelationshipsCategory 2: Negative/Hostile RelationshipsCategory 3: Ambivalent/Complex RelationshipsCategory 4: Distance RelationshipsCategory 5: Abuse RelationshipsCategory 6: Control/Power RelationshipsCategory 7: Special Relationships3.3 Emotional Relationship SVG Implementation3.4 Parent-Child Relationships3.5 Modern Family Structures4. Layout Rules4.1 Generation Alignment4.2 Couple Positioning4.3 Children Ordering4.4 Multiple Marriages4.5 Edge Crossing Minimization4.6 Spacing Rules4.7 Emotional Relationship Line Routing5. DSL Grammar (Genogram — Expanded)6. Test CasesCase 1: Nuclear Family (Basic)Case 2: Three GenerationsCase 3: Divorce + RemarriageCase 4: Medical Conditions (Color-coded)Case 5: Single IndividualCase 6: Childless CoupleCase 7: Emotional RelationshipsCase 8: Modern Family (LGBTQ+ / Donor)Case 9: Abuse + Control RelationshipsCase 10: Nonbinary / TransgenderCase 11: Cultural Heritage GenogramCase 12: Rich Annotations + In-Shape AgeCase 13: Extended Family with In-Laws7. Implementation Priority