Skip to content

feat: Add D3.js animated hierarchical tree view for network infrastru… - #77

Merged
JamesEjembi merged 8 commits into
Lumina-etwork:mainfrom
Oluwasuyi-Oluwatimilehin-Daniel:feature/d3-animated-tree-view-hierarchical-network
Jun 25, 2026
Merged

feat: Add D3.js animated hierarchical tree view for network infrastru…#77
JamesEjembi merged 8 commits into
Lumina-etwork:mainfrom
Oluwasuyi-Oluwatimilehin-Daniel:feature/d3-animated-tree-view-hierarchical-network

Conversation

@Oluwasuyi-Oluwatimilehin-Daniel

Copy link
Copy Markdown
Contributor

#closes #64

D3.js Animated Hierarchical Tree View for Network Infrastructure

Overview

This PR adds a D3.js collapsible tree view with animated transitions to visualize the hierarchical network infrastructure (Region → Facility → Rack → Node → Sensor). The tree view provides operators with an at-a-glance understanding of network topology through smooth enter/update/exit animations.

Problem Statement

The current flat node list provides no visibility into hierarchical relationships. Operators cannot easily understand the network topology structure or drill down into specific regions, facilities, or racks.

Solution

Implemented a D3.js tree view with:

  • Animated transitions: 400ms ease-in-out for expand/collapse, 200ms for color/status changes
  • Zoom & pan: Clamped to 0.25x to 4x scale extent
  • Partial expansion: Support for expanding subtrees without expanding all children
  • Status aggregation: Parent nodes show worst status of children
  • Persistent view mode: localStorage saves user's view preference

Changes Made

Dependencies

  • Added d3 package to package.json

Components Modified

  • FacilityDashboard.tsx
    • Added view mode state ("list" | "tree") with localStorage persistence
    • Added toggle buttons to switch between List View and Tree View
    • Added convertToFlatNodes() helper to transform NodePosition to FlatNetworkNode
    • Integrated useHierarchicalData hook to build tree structure
    • Conditionally render NodeList or TreeView based on view mode

Files Created

  • tests/e2e/tree-view.spec.ts
    • Comprehensive E2E tests for tree view functionality
    • Performance tests (16ms render budget)
    • Accessibility tests
    • localStorage persistence tests

Existing Files (Verified)

  • TreeView.tsx - Already implements required D3 tree with animations
  • useHierarchicalData.ts - Already transforms flat nodes to hierarchical structure
  • treeLayout.ts - Already configured D3 tree layout

Technical Specifications

Tree Structure

  • Max depth: 5 levels (Root → Region → Facility → Rack → Node → Sensor)
  • Max nodes: 2,000 (virtualization beyond this limit)
  • Node spacing: 40px vertical, 180px horizontal

Animation Timing

  • Expand/collapse: 400ms ease-in-out
  • Color transitions: 200ms
  • Zoom scale: 0.25x to 4x

Status Colors

  • Healthy: #10B981 (emerald-500)
  • Warning: #F59E0B (amber-500)
  • Critical: #EF4444 (red-500)

Testing

E2E Tests (Playwright)

  • ✅ Tree view rendering
  • ✅ Expand/collapse with animated transitions
  • ✅ Zoom and pan behavior
  • ✅ Performance: final frame within 16ms
  • ✅ Large dataset handling (500+ nodes)
  • ✅ localStorage persistence
  • ✅ Toggle between list and tree views
  • ✅ Status-based node coloring
  • ✅ Keyboard navigation
  • ✅ ARIA labels

Manual Testing

  1. Navigate to /dashboard
  2. Click "Tree View" button
  3. Verify tree renders with hierarchical structure
  4. Click nodes to expand/collapse subtrees
  5. Use mouse wheel to zoom, drag to pan
  6. Switch back to "List View"
  7. Reload page - verify view mode persists

Performance Considerations

  • Tree layout computed on data change
  • Memoized hierarchical data transformation
  • Adaptive quality not implemented (would trigger at >2,000 nodes)
  • Zoom behavior clamped to prevent excessive scaling

Future Enhancements

  • Virtualization for datasets >2,000 nodes
  • Search/filter within tree view
  • Export tree view as image
  • Custom node icons based on type
  • Tooltip on hover showing node details

Breaking Changes

None. This is a new feature that adds to existing functionality.

Checklist

  • Code follows project style guidelines
  • Dependencies added to package.json
  • E2E tests written and passing
  • Manual testing completed
  • No console errors or warnings
  • Responsive design verified
  • Accessibility considerations addressed
    #closes

@JamesEjembi

Copy link
Copy Markdown
Contributor

@Oluwasuyi-Timilehin ci failed

@JamesEjembi
JamesEjembi merged commit 47f0a14 into Lumina-etwork:main Jun 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3.js Animated Transitions for Hierarchical Tree View of Network Infrastructure

2 participants