Repository navigation
Charts: scar transitions within recaptured sharks - #137
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Days-between boxes only for transitions with at least five pairs (MIN_BOX_PAIRS): several had one or two pairs, which drew as a line. - "Closed" is "Healed", as elsewhere on /neonates (open → healing → healed); the labels come from the server so the component can't drift from them. - Chart titles name the species: both groups had two charts titled the same. Boxes use the species colour. - Plainer copy for the counts paragraph (no "identity/date"), singular and plural forms, and "No pair goes backwards" when there are none. - Section moved below the existing scar charts, at the end of /neonates. - AGENTS.md note moved out of "Adding a new season" into its own section. - Merged main, which drops the IMPORTER_VERSION bump (no import change here). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Luen
left a comment
There was a problem hiding this comment.
Reviewed against the real data (aggregates only) and current main. The pairing logic is sound:
- The stage values match the importer (
open/semi/closed). - Cross-season pairs, same-day ambiguity, identity conflicts and lab stays are excluded as #126 asks.
- Backward pairs stay in the chart.
On the real data:
| Pairs | Sharks | Open → healed, median days between captures | Backward pairs | |
|---|---|---|---|---|
| Blacktips | 210 | 184 | 28 | 0 |
| Lemons | 139 | 94 | 51.5 | 4 (healed, later recorded as open) |
I pushed fixes in f627c01, after merging main in fde91f3.
1. Boxes from one or two pairs. Several transitions had one or two pairs; blacktip open → healing had two. Their "box plot" drew as a line or a dot. A box is now drawn only from five pairs (MIN_BOX_PAIRS), and the subtitle says so. The heatmap and table still count every pair.
2. Labels. "Closed" is now "Healed", matching the rest of /neonates (the "Size by scar stage" chart reads "open → healing → healed"). The labels come from the server with each group, so the component's copy can't drift from SCAR_LABELS.
3. Duplicate titles. Both species had two charts titled "Observed scar transitions" and "Days between scar observations". The titles now name the species, which also gives each Download CSV its own name. Boxes use the species colour.
4. Copy. The counts paragraph now reads as sentences, without the "identity/date" slash. It uses singular and plural forms, and says "No pair goes backwards" when there are none. The "no tag or date" count appears only when it's above zero.
5. Smaller fixes
IMPORTER_VERSION: the bump isn't needed, because there's no import change here. Mergingmain(already at 9 for #138) drops it from the diff.- AGENTS.md: the note was inside "Adding a new season", ahead of that section's own paragraph. It now has its own "Scar transitions (#126)" section.
- Placement: the section moves to the end of /neonates, after the existing scar charts, instead of opening the page.
- Species list:
scarTransitionsmaps over['Cm', 'Na'] as const, sospeciesis typed and the component needs no cast.
Checks after the fixes: pnpm lint, pnpm check and pnpm test (93 passed, with a new test for the five-pair rule). pnpm build and pnpm test:e2e (32 passed, including the scar test). I checked /neonates on the real data, with no console errors.
Adds within-individual scar-transition heatmaps and elapsed-observation-interval box plots to /neonates, separately for blacktips and sicklefin lemons. Reports pair and distinct-shark counts, missing stages, exclusions and per-shark contributions. Backward transitions remain visible; identity conflicts, ambiguous date endpoints, season boundaries and possible lab interruptions are excluded. Intervals are explicitly not healing times.
Closes #126.
Validation: lint, svelte-check, 87 unit tests, opt-in real-data import, production build, full Playwright suite (31 passed), plus a focused mobile/keyboard/both-theme axe test. After tightening date ambiguity handling, unit/type/lint checks, build and the focused browser test were rerun successfully. No private source data committed.