Skip to content

Charts: scar transitions within recaptured sharks - #137

Merged
Luen merged 3 commits into
mainfrom
codex/126-scar-transitions
Nov 4, 2026
Merged

Luen merged 3 commits into
mainfrom
codex/126-scar-transitions

Conversation

@Luen

@Luen Luen commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

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.

@Luen Luen added analytics Charts, statistics and analyses design Visual design, theme and charts enhancement New feature or request labels Nov 3, 2026
Luen and others added 2 commits November 4, 2026 12:13
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 Luen left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. Merging main (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: scarTransitions maps over ['Cm', 'Na'] as const, so species is 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.

@Luen
Luen merged commit 5a1476f into main Nov 4, 2026
5 checks passed
@Luen
Luen deleted the codex/126-scar-transitions branch November 4, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analytics Charts, statistics and analyses design Visual design, theme and charts enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analysis: visualise umbilical-scar transitions within recaptured sharks

1 participant