Skip to content

feat: SW-1892 Add compact density variant for dashboard-tile charts#144

Open
owilliams-tetrascience wants to merge 2 commits into
mainfrom
claude/sweet-ardinghelli-7dc4d7
Open

feat: SW-1892 Add compact density variant for dashboard-tile charts#144
owilliams-tetrascience wants to merge 2 commits into
mainfrom
claude/sweet-ardinghelli-7dc4d7

Conversation

@owilliams-tetrascience

@owilliams-tetrascience owilliams-tetrascience commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a density?: "comfortable" | "compact" prop (default "comfortable") to the four dashboard-tile charts: AreaGraph, BarGraph, LineGraph, and PieChart.

"compact" swaps:

Property comfortable compact
Title font 32 14
Tick font 16 11
Axis title font 16 12
Axis title standoff per-chart (15–32) 8
Margins ~80px {l:44, r:16, b:36, t:30}

PieChart has no axes, so compact only shrinks its (HTML) title and trims the layout margins.

Density tokens live in a new shared helper src/utils/chartDensity.ts (exported from index.ts) so the charts don't each duplicate magic numbers.

Why

SW-1892: every chart ships defaults tuned for a single hero/stage chart (1000×600, 32px title, ~80px margins). Dropped into a ~600×260 dashboard tile, ~60% of the canvas is whitespace and chrome, leaving little room for data. density="compact" gives dashboard authors a one-prop opt-in without disturbing existing consumers.

Notes for reviewers

  • Existing default rendering is unchanged. Comfortable density preserves each chart's original literals (verified against the existing play tests).
  • Compact hides the cartesian legend. A horizontal legend below a 260px-tall tile triggers Plotly's automargin, which dropped the plot area to ~46–54% — below the ticket's >65% acceptance and unusable in practice. Suppressing it at compact density (gated entirely behind compact) is what makes the tile usable. Flagged in code comments.
  • Each chart gains a Compact (Dashboard Tile) story rendering inside a 600×260 card, with a play-function test asserting the plot area fills >65% of the canvas.
  • New stories leave parameters.zephyr.testCaseId as "" for sync-storybook-zephyr to backfill.

Testing

  • yarn typecheck
  • yarn lint ✅ (zero warnings)
  • yarn test ✅ (548 unit)
  • yarn test:storybook ✅ (657 storybook play tests)

🤖 Generated with Claude Code

Charts ship defaults tuned for a single hero chart (1000x600, 32px title,
~80px margins). Dropped into a ~600x260 dashboard tile, most of the canvas
is whitespace and chrome, leaving little room for data.

Add a `density?: "comfortable" | "compact"` prop (default "comfortable")
to AreaGraph, BarGraph, LineGraph, and PieChart. Compact shrinks the title
(32->14), ticks (16->11), axis titles (16->12), axis-title standoff (->8),
and margins (~80->~32). Tokens live in a shared src/utils/chartDensity.ts
helper so the charts don't each carry magic numbers.

Existing default rendering is unchanged. Compact also hides the cartesian
legend, since a legend below a 260px-tall tile triggers Plotly automargin
that drops the data area below ~50%; suppressing it keeps the plot area
above the >65% target from the ticket.

Each chart gets a "Compact (Dashboard Tile)" story rendering inside a
600x260 card, with a play-function test asserting the plot area fills
>65% of the canvas.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 19:27
@owilliams-tetrascience owilliams-tetrascience requested review from a team as code owners June 23, 2026 19:27
@vercel

vercel Bot commented Jun 23, 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 Jun 23, 2026 7:58pm

Request Review

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 an opt-in density?: "comfortable" | "compact" sizing preset to the dashboard-tile chart components so they can render with reduced “chrome” (fonts, standoffs, margins) in ~600×260 tiles, while preserving existing defaults for current consumers. The PR centralizes the compact sizing literals into a shared helper to avoid per-chart duplication and adds Storybook coverage for the compact tile configuration.

Changes:

  • Added shared chart density tokens/constants in src/utils/chartDensity.ts and exported them from the package entrypoint.
  • Updated AreaGraph, BarGraph, LineGraph, and PieChart to accept density and apply compact fonts/margins (and hide cartesian legends in compact).
  • Added “Compact (Dashboard Tile)” stories with play-function assertions for the compact tile rendering.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utils/chartDensity.ts Introduces shared density tokens + compact margin/standoff constants.
src/index.ts Exports the new chart density helper from the public entrypoint.
src/components/charts/AreaGraph/AreaGraph.tsx Adds density prop and applies compact tokens to fonts/margins/standoff/legend.
src/components/charts/AreaGraph/AreaGraph.stories.tsx Adds compact dashboard-tile story + plot-area fill play assertion.
src/components/charts/BarGraph/BarGraph.tsx Adds density prop and applies compact tokens to fonts/margins/standoff/legend.
src/components/charts/BarGraph/BarGraph.stories.tsx Adds compact dashboard-tile story + plot-area fill play assertion.
src/components/charts/LineGraph/LineGraph.tsx Adds density prop and applies compact tokens to fonts/margins/standoff/legend.
src/components/charts/LineGraph/LineGraph.stories.tsx Adds compact dashboard-tile story + plot-area fill play assertion.
src/components/charts/PieChart/PieChart.tsx Adds density prop and applies compact title sizing + trimmed Plotly margins.
src/components/charts/PieChart/PieChart.stories.tsx Adds compact dashboard-tile story + compact title assertion.

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

Comment thread src/utils/chartDensity.ts
Comment thread src/components/charts/PieChart/PieChart.stories.tsx
- chartDensityTokens accepts optional/undefined density so it can be
  called directly with an optional `density?` prop
- PieChart compact story now sizes the chart to the 600x260 tile
  (width 600, height = plot height that leaves room for title + legend)
  instead of a centered 260x260 chart, so it demonstrates real tile usage

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

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 94.76% (🎯 83%)
⬆️ +0.02%
20678 / 21821
🟢 Statements 94.76% (🎯 83%)
⬆️ +0.02%
20678 / 21821
🟢 Functions 93.59% (🎯 74%)
⬆️ +0.01%
920 / 983
🟢 Branches 88.82% (🎯 81%)
⬆️ +0.08%
3798 / 4276
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/components/charts/AreaGraph/AreaGraph.tsx 99.63%
⬆️ +0.01%
83.33%
⬆️ +3.33%
100%
🟰 ±0%
99.63%
⬆️ +0.01%
65
src/components/charts/BarGraph/BarGraph.tsx 99.53%
⬆️ +0.03%
87.5%
⬆️ +4.17%
100%
🟰 ±0%
99.53%
⬆️ +0.03%
125
src/components/charts/LineGraph/LineGraph.tsx 96.96%
⬆️ +0.13%
86.11%
⬆️ +3.36%
100%
🟰 ±0%
96.96%
⬆️ +0.13%
327-333
src/components/charts/PieChart/PieChart.tsx 100%
🟰 ±0%
80.95%
⬆️ +4.48%
100%
🟰 ±0%
100%
🟰 ±0%
src/utils/chartDensity.ts 100% 100% 100% 100%
Generated in workflow #812 for commit 8f92458 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.

3 participants