diff --git a/NUCLEAR_FAMILY_TREE.md b/NUCLEAR_FAMILY_TREE.md index fab01f5..9a4b9eb 100644 --- a/NUCLEAR_FAMILY_TREE.md +++ b/NUCLEAR_FAMILY_TREE.md @@ -1,141 +1,157 @@ -# Nuclear Family Tree Network View Documentation +# D3.js Interactive Family Tree Documentation -The Nuclear Family Tree Network View provides an interactive visualization of immediate family relationships, showing the current person with their spouse, parents, and children in a connected network layout. +The D3.js Interactive Family Tree provides a professional, library-powered visualization of biblical genealogies with interactive navigation, zoom controls, and hierarchical family relationships using the industry-standard D3.js library. ## Features Overview -### 🌳 Interactive Nuclear Family Network -- Visual network layout showing immediate family relationships +### 🌳 D3.js Powered Family Tree +- Professional hierarchical tree layout using D3.js library +- Interactive zoom and pan controls for navigation +- Expandable/collapsible tree nodes for large genealogies - Color-coded family members by role (current person, spouse, parents, children) -- Connection lines showing marriage and parent-child relationships -- Clickable nodes to navigate between family members -- Responsive positioning that adapts to screen size +- Smooth transitions and animations +- Responsive design that adapts to screen size ### 🎯 Key Capabilities -- **Network Visualization:** Positioned family members with connecting lines +- **Professional Tree Layout:** D3.js tree algorithm for optimal positioning +- **Interactive Controls:** Zoom, pan, center, expand/collapse functionality - **Role-Based Coloring:** Visual distinction between family roles - **Interactive Navigation:** Click any family member to select them -- **Connection Types:** Marriage lines (horizontal, green) and parent-child lines (vertical, blue) +- **Connection Types:** Tree links for parent-child and marriage relationships - **Mobile Responsive:** Adaptive layout for different screen sizes -- **Visual Legend:** Color-coded legend explaining family member roles +- **Tree View Default:** Interactive tree is the primary view mode ## Technical Implementation ### 1. View Toggle System +- **Tree View (Default):** D3.js interactive family tree visualization - **Details View:** Traditional list-based family information -- **Tree View:** Nuclear family network visualization - Toggle buttons allow switching between views -- View preference maintained during person selection +- Tree view loads by default for better user experience -### 2. Nuclear Family Network Layout +### 2. D3.js Tree Implementation ```javascript -// Responsive positioning system -const positions = { - current: { x: containerWidth * 0.3, y: containerHeight * 0.4 }, - spouse: { x: containerWidth * 0.6, y: containerHeight * 0.4 }, - parent1: { x: containerWidth * 0.2, y: containerHeight * 0.1 }, - parent2: { x: containerWidth * 0.5, y: containerHeight * 0.1 }, - children: [] // Dynamically positioned based on number of children -}; +// D3.js tree layout with zoom and pan +function initializeD3Tree() { + svg = d3.select("#tree-svg"); + zoom = d3.zoom() + .scaleExtent([0.1, 3]) + .on("zoom", (event) => { + g.attr("transform", event.transform); + }); + tree = d3.tree().size([height - 100, width - 200]); +} ``` -### 3. Family Member Roles and Colors -- **Current Person:** Primary blue background with white text -- **Spouse:** Light green background (#e8f5e8) with green border -- **Parents:** Light yellow background (#fff3cd) with yellow border -- **Children:** Light red background (#f8d7da) with red border +### 3. D3.js Node Styling +- **Current Person:** Primary color circle with bold white text +- **Spouse:** Green circle (#e8f5e8) with green stroke +- **Parents:** Yellow circle (#fff3cd) with yellow stroke +- **Children:** Red circle (#f8d7da) with red stroke +- **Hover Effects:** Animated circle radius and stroke changes -### 4. Connection Line System +### 4. D3.js Link System ```javascript -// Three types of connection lines -- Marriage Lines: Horizontal green lines connecting spouses -- Parent-Child Lines: Vertical blue lines connecting generations -- Dynamic Positioning: Lines calculated based on element positions +// D3.js hierarchical links +const links = g.selectAll('.tree-link') + .data(treeLayout.links()) + .enter() + .append('path') + .attr('d', d3.linkHorizontal()); + +// Marriage connections +const spouseLinks = g.selectAll('.spouse-link') + .attr('class', 'tree-link marriage'); ``` -## Network Layout Structure +## D3.js Tree Structure -### **Family Positioning:** +### **Hierarchical Layout:** ``` - [Parent 1] [Parent 2] - \ / - \ / - \ / - [Current Person] ——— [Spouse] - | - | - [Child 1] [Child 2] [Child 3] + [Parent 1] — [Parent 2] + | + [Current Person] ——— [Spouse] + | + ┌────┼────┐ +[Child 1] [Child 2] [Child 3] ``` -### **Connection Types:** -- **Marriage Connection:** Horizontal line between current person and spouse -- **Parent-Child Connections:** Vertical lines from parents to current person -- **Children Connections:** Vertical lines from current person (and spouse) to children +### **D3.js Features:** +- **Tree Algorithm:** Automatic optimal positioning using D3.js tree layout +- **Zoom Controls:** Mouse wheel and button controls for navigation +- **Pan Support:** Drag to move around large family trees +- **Smooth Transitions:** Animated updates when changing focus person ## User Interface Features ### **Interactive Elements:** - **Clickable Nodes:** All family members are clickable for navigation -- **Hover Effects:** Scale and shadow effects on family member hover -- **Role Indicators:** Text labels showing family role (Current, Spouse, Parent, Child) -- **Visual Legend:** Color-coded legend explaining family member types +- **Hover Effects:** Animated circle radius and stroke changes +- **Tree Controls:** Center, Expand All, Collapse All buttons +- **Zoom/Pan:** Mouse controls for navigating large family trees +- **Role Colors:** Visual distinction through circle colors and strokes ### **Responsive Design:** -- **Desktop:** Full 500px height with optimal spacing -- **Mobile:** Reduced to 350px height with compressed layout -- **Adaptive Positioning:** Percentage-based positioning for different screen sizes -- **Scalable Text:** Font sizes adjust for mobile viewing +- **Desktop:** Full 600px height with D3.js optimal spacing +- **Mobile:** Reduced to 400px height with responsive text +- **SVG Scaling:** Vector graphics scale perfectly on all devices +- **Touch Support:** Touch-friendly controls for mobile interaction ## Implementation Details -### **Family Member Creation:** +### **D3.js Node Creation:** ```javascript -function createFamilyMember(person, personId, role, position) { - const member = document.createElement('div'); - member.className = `family-member ${role}`; - member.onclick = () => selectPerson(personId); - member.style.left = `${position.x}px`; - member.style.top = `${position.y}px`; +function updateD3Tree(person, personId) { + const root = d3.hierarchy(treeData); + const treeLayout = tree(root); - member.innerHTML = ` -