Skip to content

Add Charts2 Storybook samples#9

Merged
xrendan merged 14 commits into
masterfrom
codex/charts2-storybook-samples
Jul 10, 2026
Merged

Add Charts2 Storybook samples#9
xrendan merged 14 commits into
masterfrom
codex/charts2-storybook-samples

Conversation

@xrendan

@xrendan xrendan commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

  • add the Charts2 package and include its stories in the root Storybook config
  • add CLI-ready sample chart definitions for the supported chart families
  • render the actual embedded Build Canada square / Canada Spends SVG logos in top-right chart chrome
  • size the logo to the rendered height of the title plus subtitle block
  • keep chart title and subtitle rendering in Söhne Kräftig, with SVG markup coverage
  • add descending x-axis tick marks, dashed y-axis spacing gridlines, dashed vertical value markers without duplicate bottom stubs, and production-style Grapher palettes
  • add sample, axis, chrome, theme, SceneSVG, and corpus coverage for these visual defaults

Verification

  • bun test src/core/layout/axis.test.ts
  • bun test src/core/layout/axis.test.ts src/core/layout/chrome.test.ts src/react/SceneSVG.test.tsx src/core/theme/themes.test.ts src/samples.test.ts
  • bun test src/corpus/corpus.test.ts
  • bun run typecheck
  • bun src/cli/index.ts render samples/line-provincial-budgets.json --out -

Note: earlier, bun test src/cli/render.test.ts was run; the existing PNG rasterization smoke test timed out after 5s, while the rest of that file passed.

@xrendan
xrendan force-pushed the codex/charts2-storybook-samples branch 3 times, most recently from df66fa9 to 253a8b9 Compare June 12, 2026 16:03
@xrendan
xrendan force-pushed the codex/charts2-storybook-samples branch from 253a8b9 to 8af4421 Compare June 12, 2026 16:30
xrendan added 13 commits June 12, 2026 10:40
Implements two chart-definition features that previously parsed but did
not render (spec 09, spec 02).

Faceting (small multiples):
- facet: "entity" | "metric" lays out a grid of panels balanced to the
  frame aspect ratio, with per-panel titles and a 16-panel cap.
- Panels share one value domain (two-pass union) so gridlines align, and
  a shared legend sits above the grid for multi-series facets. Falls back
  to a single chart when only one panel would result.

Comparison lines:
- comparisonLines render horizontal (y) and vertical (x/time) reference
  lines with labels on line and stacked-area charts; out-of-range lines
  are skipped. Other chart types emit a comparison-lines-unsupported
  warning instead of dropping the config silently.

Chart layers now expose valueDomain for the faceting two-pass. Adds unit
tests for both features, Storybook stories (Charts2/Faceting,
Charts2/ComparisonLines), and CLI sample definitions.
…e focus

Single checkpoint of in-flight work across several streams on this branch:

- Theme rework: chrome colours sourced from @buildcanada/colours
  (linen/charcoal/nickel/auburn); larger title/subtitle fonts; emphasis
  dimOpacity 0.35 -> 0.2. Corpus goldens re-blessed to match.
- New chart types: slope, dumbbell, scatter, marimekko (layouts, goldens,
  stories, tests) wired into the layout registry.
- Interactive chrome rethemed to the Build Canada palette; flush tab row;
  new @buildcanada/components primitives (Popover, RadioGroup, Select,
  SegmentedControl, Slider, IconButton).
- Line-chart focus: hovering/clicking a series' end label emphasizes it
  (spec 07 §3), non-focused lines/labels dim to 0.2 and their markers hide;
  forceable via `charts render --focus <series>` and the Chart
  `focusedSeries` prop.
- CLI: scaffold + install-skill commands.
- Adds the charts3 DOM-free engine experiment and the specs/ directory.

Stray CLI render artifacts (chart.png/chart.svg) intentionally left
untracked.
Deletes the packages/charts3 experiment (DOM-free engine slice) and all
references: root build:charts3 / build:packages scripts, the workspace
lockfile entry, and the spec 28 mention. charts3 was untracked into the
tree by the prior WIP checkpoint and is not a dependency of any package.
… tests

- ci.yml: run `build:packages` before the typecheck and build jobs (the
  test job already did), so charts2 can resolve @buildcanada/components —
  it now imports the primitives after the chrome retheme.
- inkWidth.test.ts: skip when the (gitignored) brand TTF is absent instead
  of hard-throwing, so the rasterization acceptance test doesn't fail CI.
- DownloadModal.test.tsx: mark the known-bug reproduction `it.fails()` so
  it is expected-to-fail rather than breaking CI (re-flags if the bug is
  fixed).
An orphaned snapshot entry remained in layoutChart.test.ts.snap; vitest
under CI=true treats obsolete snapshots as a failure. All 70 matrix
assertions already pass — this only removes the dead entry, no fingerprints
change.
- formatValue gains prefix/suffix, wired through ColumnMeta, the manifest
  column schema, and per-column binding overrides. An explicit suffix
  suppresses auto-abbreviation (the value is already at that scale), so
  pre-scaled figures render cleanly: en "$192.9B", fr "192,9B $". Negatives
  and sign preserved. Columns without prefix/suffix are byte-for-byte
  unchanged.
- Annotate the dollar columns in the provincial-budgets, federal-departments
  and government-debt fixtures with the B/M scale suffix (data not rescaled);
  denominator-derived "% of GDP" columns left alone.
- Re-bless 26 corpus goldens and update the unit tests whose formatted
  strings shifted (number, DataTable, EntitySelector, dumbbell, marimekko,
  layoutChart snapshot).
- Axis ticks (verbosity "tick") trim trailing zeros while still respecting
  the column's decimal cap, so a round tick reads "$50B" not "$50.0B";
  integer columns stay whole and genuinely fractional ticks keep their
  digits. Data labels and tooltips keep their fixed decimals.
- A zero value never carries a scale suffix: "$0", never "$0B" — applied on
  every surface.

Re-blessed the corpus and refreshed the layoutChart matrix snapshot; added
regression cases in number.test.ts.
Set @buildcanada/colours, components, charts, and charts2 to 0.4.0, and
update the inter-package dependency ranges (charts, charts2 → colours,
components) to ^0.4.0. Lockfile unchanged: workspace packages resolve by
path, so `bun install --frozen-lockfile` stays satisfied.
@xrendan
xrendan merged commit 2e4a006 into master Jul 10, 2026
8 of 10 checks passed
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.

1 participant