Skip to content

Charts: measurement coverage and catch-model sample selection - #152

Merged
Luen merged 2 commits into
mainfrom
codex/123-measurement-coverage
Nov 4, 2026
Merged

Luen merged 2 commits into
mainfrom
codex/123-measurement-coverage

Conversation

@Luen

@Luen Luen commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Adds measurement-availability heatmaps to /data-quality, with recorded/eligible counts and CSV exports for field captures and gillnet sets. Zero values remain recorded; empty denominators remain missing. Lavage-result coverage uses the sampled-or-result-present subset and separately reports unknown and explicitly unsampled records.

Adds selection-flow charts to /drivers and extracts the model's existing filters into selectCatchModel(), so chart counts and fitted samples use the same rules. Selection eligibility is explicitly distinguished from a successful fit.

Also makes shared horizontally scrolling data tables keyboard reachable; mobile axe testing exposed the existing issue while validating the new coverage tables.

Closes #123. Closes #150.

Validation: lint; svelte-check (0 errors/warnings); 97 unit tests; read-only real-data import; production build; full Playwright suite, including new mobile/light/dark accessibility coverage. Browser checks use an ignored local configuration with a separate port. No source spreadsheets or local test configuration committed.

@Luen Luen added accessibility Barrier affecting people with disabilities enhancement New feature or request analytics Charts, statistics and analyses data-quality Issues in the source spreadsheets for the lab to review labels Nov 4, 2026
- Coverage copy: dashed cells (not grey) mark no eligible records, and the
  colours flip in dark mode, so cells now carry their share as a label
  (>99% and <1% instead of rounding to 100% or 0%). Plainer wording.
- Set panel adds start time and crew size, both fields the model needs.
- Coverage moves below the import summary on /data-quality.
- Selection flow: one chart instead of three near-identical ones; short
  labels, a rule column, nursery counts, thresholds from exported
  constants, species names instead of codes, and which variables the
  incomplete sets lack (overlapping). It sits in the model section and
  also shows when the model can't be fitted (the synthetic fixture).
- Tests reconcile the flow with the fitted sample sizes.
- DataTable: scroll regions get a name per table and keep a tab stop only
  when they overflow (every table rendered focusable on the server).
- Heatmap: labels on the strong end of the sequential scale were white
  in dark mode, where those cells are pale; new --seq-strong-ink token.
- AGENTS.md notes moved into the catch model list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Luen

Luen commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed against the real data (aggregates only) and current main. The core is right:

On the real data the flow reconciles with catchModel(), including n, dropped (79) and each species n:

Step Sets
Timed gillnet sets 1,185
Every model variable recorded 1,134
Nurseries with ≥ 30 such sets (all sharks, blacktips) 1,106
Sicklefin lemon model 651

I pushed fixes in 8a5cdc0.

1. The copy described colours that aren't on the chart. "Grey means no eligible records" no longer holds: since #136, empty cells are dashed outlines. "Pale blue means 0%, dark blue 100%" is reversed in dark mode, where the scale runs from dark to pale. Each cell now shows its share as a label. Shares just short of 100% or just above 0% read ">99%" and "<1%", so they don't round to a complete or empty column. The copy explains dashed cells without naming colours.

2. Heatmap labels in dark mode (shared, existing bug). Labels on the strong end of the scale were always white. In dark mode those cells are pale (--seq-7 is #cde2fb), so the labels were unreadable. A new --seq-strong-ink token is white in light mode and the page colour in dark. This also fixes the labelled heatmaps already on /effort, /nurseries, /pressure and /recaptures.

3. Three nearly identical selection charts. On the real data all three matched in the first three bars, and the all-shark chart matched the blacktip one throughout. It's now one chart: the three shared filters, then the two species models, labelled as starting again from the all-shark sample. Also:

  • Species names instead of "Cm" and "Na".
  • Short bar labels, since the long ones were cut off. Each rule is in the table's "Keeps" column, with a nursery count.
  • Thresholds come from exported constants (MIN_SITE_SETS, MIN_SITE_CATCH, MIN_MODEL_SETS), not numbers typed into the copy.
  • A sentence on what the incomplete sets lack, marked as overlapping: of 51, 48 lack the tide, 4 the crew size and 1 the SST.

4. Placement. Both sections opened their pages, ahead of the pages' own content.

  • The selection flow now ends the model section, next to "About the model", which already gives the dropped count.
  • Coverage sits between the import summary and the notes list on /data-quality.

5. A chart for when there's no model. The fixture's 40 sets can't fit the model, so {#if md} hid the flow exactly when it explains the most. Without a model, the section now says why and shows the flow, which also lets e2e test it. I filed #153 for a fixture that does fit.

6. Scrollable tables (#150). role="region" with tabindex="0" on every DataTable gave every table a tab stop and the same landmark name, "Scrollable data table", even tables that don't scroll. Now:

  • Each table has its own name. ChartCard passes "Data: <title>", and the three /data-quality tables are named.
  • After mount, only tables that overflow keep the tab stop.
  • The server still renders every table focusable, so axe passes before hydration.

7. Smaller fixes

  • Set panel: adds start time and crew size. Both are field records and model variables.
  • Payload: percentages are rounded to one decimal on the server; they were full floats in the page data.
  • Copy: singular and plural forms on the lavage counts, and plainer wording throughout.
  • Unit tests: the flow reconciles with the model's sample sizes, species steps restart from the all-shark sample, and empty strata stay null.
  • e2e: renamed to measurement-coverage.spec.ts. It also checks that the notes table takes focus at phone width.
  • AGENTS.md: the note was a separate paragraph above the catch-model list; it's now two bullets in the list.

Merging with #151. Both PRs edit /drivers and the catch model. A trial merge is clean in either order and passes pnpm check (see #151 for the one structural change that took).

Checks after the fixes:

  • pnpm lint, pnpm check and pnpm test (98 passed), plus the opt-in real-data import.
  • pnpm build and the full Playwright suite: everything passed except the new /drivers test, which needed fix 5. After that fix, the coverage and pages specs passed (33 tests).
  • In the browser on the real data: /data-quality and /drivers in light and dark, and /effort for fix 2.

@Luen
Luen merged commit de5a126 into main Nov 4, 2026
5 checks passed
@Luen
Luen deleted the codex/123-measurement-coverage branch November 4, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Barrier affecting people with disabilities analytics Charts, statistics and analyses data-quality Issues in the source spreadsheets for the lab to review enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility: make horizontally scrolling data tables keyboard reachable Charts: show measurement coverage by season and analysis eligibility

1 participant