Commit e2ccaa9
authored
## Summary
Implements issue #13 - Interactive Radioactive Decay Chain Visualization
This PR adds a comprehensive interactive decay chain visualization
system that shows multi-generation radioactive decay pathways. Key
features:
- **Multi-generation decay tree building** - Recursive depth-first
traversal of RadioNuclides table (46,797 decay records)
- **Interactive zoom/pan/pinch controls** - Using react-zoom-pan-pinch
library (25KB) with both UI controls and mouse/touch gestures
- **Horizontal left-to-right layout** - Reingold-Tilford-inspired tree
layout algorithm optimized for wide decay chains
- **Mutually exclusive row expansion** - Only one decay chain visible at
a time for cleaner UX
- **Responsive table height** - Auto-adjusts when filter panels
expand/collapse using transitionend events
## Implementation Details
**New Files:**
- `src/services/decayChainService.ts` - Core service for building decay
chains from database
- `src/components/DecayChainDiagram.tsx` - Interactive SVG visualization
with zoom controls
- `src/constants/decaySeries.ts` - Famous natural decay series metadata
(U-238, Th-232, U-235, Np-237)
**Modified Files:**
- `src/pages/ShowElementData.tsx` - Replaced expanded decay rows with
DecayChainDiagram
- `src/components/NuclideDetailsCard.tsx` - Added decay chain section
for radioactive nuclides
- `src/components/SortableTable.tsx` - Added expandedContentNoPadding
prop and fixed table height recalculation
- `src/types/index.ts` - Added DecayChainNode and DecayChainResult
interfaces
**Critical Bug Fix:**
- Fixed `isNuclideStable()` to check RadioNuclides table FIRST before
logHalfLife threshold
- Previously, U-238 (logHalfLife=9.65) was incorrectly marked stable
despite having decay data
## UI Changes
**Decays Tab (ShowElementData):**
- Clicking a decay row now expands an interactive decay chain diagram
- Zoom controls: Auto-fit, zoom in/out, reset
- Mouse wheel to zoom, click-and-drag to pan, double-click to zoom in
- Mobile: pinch-to-zoom and drag to pan
- Only one row expands at a time for focused viewing
**Integrated Tab (NuclideDetailsCard):**
- Added "Radioactive Decay Chain" section for radioactive nuclides
- Interactive controls for adjusting max depth (1-10 generations) and
minimum branching ratio (1-100%)
- Collapsible section to save space for stable nuclides
## Technical Details
**Layout Algorithm:**
- Horizontal tree layout with configurable spacing
- Left-to-right progression through decay generations
- SVG-based rendering with curved edges
- Color-coded nodes: radioactive (red), stable (green), unknown
stability (gray)
**Performance:**
- Configurable max depth prevents infinite loops in decay cycles
- Branching ratio threshold filters minor decay paths
- Virtualized table rendering handles large datasets
**Dependencies:**
- Added: react-zoom-pan-pinch (25KB gzipped) for zoom/pan functionality
## Test Plan
- [x] View decay chain for U-238 (14 generations, 18 branches)
- [x] Verify horizontal left-to-right layout
- [x] Test zoom controls (auto-fit, zoom in/out, reset)
- [x] Test mouse wheel zoom and click-and-drag pan
- [x] Test double-click to zoom in
- [x] Test mobile pinch-to-zoom (Safari/Chrome on iOS/Android)
- [x] Verify mutually exclusive row expansion in Decays tab
- [x] Verify table height adjusts when filter panel expands/collapses
- [x] Verify no page scrolling with expanded decay chains
- [x] Test with various nuclides (Th-232, U-235, Np-237)
- [ ] E2E tests for decay chain rendering
- [ ] E2E tests for zoom/pan interactions
- [ ] Cross-browser testing (Chrome, Firefox, Safari)
## Screenshots
### Decays Tab - Expanded Row
<img width="1280" height="1024" alt="image"
src="https://github.com/user-attachments/assets/a42779d9-b63a-47c7-8f0a-1d7203bd4cd9"
/>
>Interactive decay chain replaces simple parent→daughter→granddaughter
display
### Integrated Tab - Nuclide Details
<img width="1280" height="1024" alt="image"
src="https://github.com/user-attachments/assets/ac572b15-cec7-416d-a75e-413dc974967c"
/>
>Full decay chain with controls for depth and branching ratio
---
Closes #13
1 parent 4db68c3 commit e2ccaa9
10 files changed
Lines changed: 1189 additions & 183 deletions
File tree
- src
- components
- constants
- pages
- services
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
138 | 187 | | |
139 | 188 | | |
140 | 189 | | |
| |||
146 | 195 | | |
147 | 196 | | |
148 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
149 | 201 | | |
150 | 202 | | |
151 | 203 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
0 commit comments