Skip to content

feat: SW-2099 Reference-line / annotation layer — thresholds & bands for charts#166

Open
owilliams-tetrascience wants to merge 6 commits into
mainfrom
SW-2099-annotation-layer
Open

feat: SW-2099 Reference-line / annotation layer — thresholds & bands for charts#166
owilliams-tetrascience wants to merge 6 commits into
mainfrom
SW-2099-annotation-layer

Conversation

@owilliams-tetrascience

@owilliams-tetrascience owilliams-tetrascience commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements SW-2099 (VIZ-2) — a shared, opt-in annotation layer for ts-lib-ui-kit charts: threshold/reference lines and shaded bands, rendered as themed Plotly shapes and labeled annotations.

Net-new enabler (VIZ-4, VIZ-8, VIZ-9, VIZ-10, VIZ-12 build on it). Use-case source: HTS Hit Finder — Global Filtering page.

What's included

  • src/utils/chart-annotations.ts — shared builder + public types
    • ReferenceLine ({ axis, value, label?, color?, width?, dash? }) — vertical (axis:'x') or horizontal (axis:'y') threshold line spanning the full plot
    • Band ({ axis, from, to, label?, color?, opacity? }) — shaded from–to region (pass/fail, ±σ)
    • buildChartAnnotations(theme, config){ shapes, annotations } to spread into a Plotly layout
  • Opt-in props on Histogram and InteractiveScatterreferenceLines / bands. Additive, no breaking changes.
  • Reference lines draw layer:"above" (visible over bars/points); bands draw layer:"below" (data stays readable). Label tags get a theme-aware opaque backing + colored border so they're legible in light and dark mode.
  • Exported from src/index.ts.

API (matches the ticket)

<Histogram referenceLines={[{ axis: "x", value: 0.7, label: "cutoff" }]} bands={[{ axis: "x", from: 24, to: 40, label: "pass" }]} />
<InteractiveScatter referenceLines={[{ axis: "y", value: 70, label: "hit line" }]} bands={[{ axis: "x", from: 70, to: 100, label: "focus" }]} />

Screenshots

Rendered from the new Storybook stories (light + dark).

Histogramcutoff reference line + pass band

Light Dark

InteractiveScatterhit line / midpoint reference lines + focus band

Light Dark

Acceptance criteria

  • Reference-line + band stories on Histogram and Scatter
  • Labels legible in light + dark mode (verified in Storybook, both themes)
  • Storybook stories + play tests
  • Exported from src/index.ts

Testing

  • yarn typecheck ✓ · yarn lint (zero warnings) ✓ · yarn test ✓ (763 tests, incl. 10 new for the pure builder)
  • Verified all 4 new stories render in Storybook (light + dark); shape counts and label text confirmed via DOM.

New stories intentionally carry zephyr.testCaseId: "" — apply the zephyr_sync label to generate IDs.

🤖 Generated with Claude Code

Adds a shared, opt-in annotation layer for charts: threshold/reference
lines and shaded from-to bands, rendered as themed Plotly shapes and
labeled annotations. Wired as additive `referenceLines` / `bands` props
on Histogram and InteractiveScatter (no breaking changes).

Labels use a theme-aware opaque backing so they stay legible in light
and dark mode. Includes Storybook stories with play tests (light + dark)
on both charts, a unit test for the pure builder, and exports the types
from src/index.ts.

SW-2099

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 8, 2026 01:46
@owilliams-tetrascience
owilliams-tetrascience requested review from a team as code owners July 8, 2026 01:46
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ts-lib-ui-kit-storybook Ready Ready Preview, Comment Jul 16, 2026 1:34pm

Request Review

@owilliams-tetrascience owilliams-tetrascience changed the title SW-2099: Reference-line / annotation layer — thresholds & bands for charts feat: SW-2099 Reference-line / annotation layer — thresholds & bands for charts Jul 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a reusable, opt-in Plotly annotation layer to the UI kit’s chart components, enabling threshold/reference lines and shaded bands with theme-aware labeling for light/dark mode.

Changes:

  • Introduces buildChartAnnotations() plus public types (ReferenceLine, Band) to generate Plotly shapes + annotations.
  • Adds referenceLines / bands props to Histogram and InteractiveScatter and wires the generated shapes into their Plotly layouts.
  • Adds unit tests for the builder and new Storybook stories + play assertions for both charts (including dark-mode variants).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/utils/chart-annotations.ts New shared builder/types for Plotly shapes + annotations for reference lines and bands.
src/utils/chart-annotations.test.ts Unit tests covering shape/annotation output, ordering, and theme-backed label styling.
src/index.ts Re-exports the new chart annotation utilities from the package entrypoint.
src/components/charts/InteractiveScatter/types.ts Adds opt-in referenceLines / bands props to the public props interface.
src/components/charts/InteractiveScatter/InteractiveScatter.tsx Builds annotation layer via buildChartAnnotations() and applies it to the Plotly layout.
src/components/charts/InteractiveScatter/InteractiveScatter.stories.tsx Adds “reference lines + bands” stories with play assertions (light + dark).
src/components/charts/Histogram/Histogram.tsx Adds opt-in props and merges annotation layer into the Plotly layout.
src/components/charts/Histogram/Histogram.stories.tsx Adds “reference line + band” stories with play assertions (light + dark).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/chart-annotations.ts
Comment thread src/utils/chart-annotations.ts
Comment thread src/components/charts/Histogram/Histogram.stories.tsx
Comment thread src/components/charts/Histogram/Histogram.stories.tsx Outdated
Comment thread src/components/charts/InteractiveScatter/InteractiveScatter.stories.tsx Outdated
- Add "longdashdot" to ReferenceLineDash so the full set of Plotly dash
  styles is accepted.
- Re-export usePlotlyTheme / PlotlyThemeColors from the package entrypoint
  so buildChartAnnotations' signature is nameable without a deep import.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The `globals.theme` toggle sets `.dark` in the Storybook UI, but the
@storybook/addon-vitest runner doesn't propagate it to documentElement,
so `useIsDark` never saw it and the "dark mode is active" assertion
failed in CI. Drive the class from the play function (with cleanup) so
the component genuinely renders dark during the test, and drop the
brittle infrastructure assertion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Dark mode is viewable on any story via the Storybook theme toggle, so
separate dark-mode stories are redundant. Keep the light reference-line
+ band stories for both charts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Labeled reference lines and bands now surface in each chart's legend
instead of as on-plot text tags. The shared builder returns chart-
agnostic legendItems; InteractiveScatter renders them via Plotly's
legend (annotationLegendTraces), and Histogram folds them into its
custom HTML legend (line swatch for lines, filled box for bands).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 96.61% (🎯 83%)
⬆️ +0.03%
22408 / 23193
🟢 Statements 96.61% (🎯 83%)
⬆️ +0.03%
22408 / 23193
🟢 Functions 95.77% (🎯 74%)
⬆️ +0.03%
974 / 1017
🟢 Branches 90.23% (🎯 81%)
⬇️ -0.06%
4276 / 4739
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/components/charts/Histogram/Histogram.tsx 99.71%
⬆️ +0.04%
89.55%
⬇️ -5.27%
100%
🟰 ±0%
99.71%
⬆️ +0.04%
182
src/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.tsx 100%
🟰 ±0%
97.43%
⬇️ -0.78%
100%
🟰 ±0%
100%
🟰 ±0%
src/components/charts/ScatterPlotInteractive/types.ts 100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
src/utils/chart-annotations.ts 100% 92.59% 100% 100%
Generated in workflow #1009 for commit 366e5e2 by the Vitest Coverage Report Action

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.

2 participants