Skip to content

Add interactive dashboard with Build Canada charts library#15

Open
xrendan wants to merge 3 commits into
mainfrom
claude/integrate-graphing-library-jxAOK
Open

Add interactive dashboard with Build Canada charts library#15
xrendan wants to merge 3 commits into
mainfrom
claude/integrate-graphing-library-jxAOK

Conversation

@xrendan
Copy link
Copy Markdown
Member

@xrendan xrendan commented May 8, 2026

Summary

This PR adds a new interactive dashboard page that showcases the @buildcanada/charts library's Grapher component with life expectancy data visualization capabilities.

Key Changes

  • New Dashboard Page (src/app/dashboard/page.tsx): Server component that sets up metadata and imports the Build Canada charts stylesheet
  • Dashboard Component (src/app/dashboard/Dashboard.tsx): Interactive client component featuring:
    • Multiple chart type options (Line, Discrete Bar, Stacked Area, Slope)
    • Entity preset selection (G7, Americas, Asia regions)
    • Responsive sizing that adapts to viewport dimensions
    • Life expectancy data visualization using the LifeExpectancyGrapher
  • Dynamic Loading Wrapper (src/app/dashboard/DashboardClient.tsx): Client-side dynamic import with SSR disabled and loading skeleton for better UX
  • Dependencies: Added @buildcanada/charts, @buildcanada/colours, @buildcanada/components, mobx, mobx-react, and sass to support the charting library

Implementation Details

  • The dashboard uses React hooks (useState, useMemo, useEffect) to manage chart type, entity selection, and responsive sizing
  • Window resize listener ensures the chart dimensions scale appropriately between 420-660px height and up to 1100px width
  • Chart state is memoized based on chart type, preset index, and dimensions to optimize re-renders
  • UI includes segmented button group for chart type selection and dropdown for entity presets
  • Includes user guidance text and instructions for chart interactivity

https://claude.ai/code/session_01H5n1EL6QDosMXGTS8UndR9

claude added 3 commits May 7, 2026 22:47
Wires the @buildcanada/charts library (plus its @buildcanada/colours and
@buildcanada/components peers) into TradingPost as file: dependencies
pointing at the sibling bcds checkout. The dashboard renders an
interactive Grapher with the LifeExpectancyGrapher sample dataset and
exposes controls to switch chart type (Line / Discrete Bar /
Stacked Area / Slope) and entity preset.

Notes on the integration:

- The Grapher component uses MobX, mounts via observers that touch
  window/document, and is not RSC-safe. The page boundary loads it via
  next/dynamic with ssr: false from a client wrapper so Next does not
  try to prerender it (mobx decorators initialize on import, so even
  SSR of an otherwise-client component fails).
- @buildcanada/charts ships a single SCSS entry point as its
  './styles.css' export. Adding 'sass' as a dependency lets Next
  compile that .scss directly when imported from the dashboard route.
- mobx (^6.15) and mobx-react (^7.6) are required as peer deps by the
  charts package. mobx-react 7.6 still declares React 16/17/18 as its
  peer but works against React 19 for the @observer usage in Grapher.

Together with the matching fix in bcds (TC-39 stage 3 decorator emit +
automatic JSX runtime in the charts build), /dashboard now mounts the
Grapher cleanly and survives chart-type / entity-preset switching.
Now that bcds#7 is merged and @buildcanada/charts@0.3.9 is published
(with the TC-39 stage 3 decorator emit + automatic JSX runtime fix),
TradingPost no longer needs the local file:../bcds/packages/* links.
Switching to ^0.3.9 / ^0.3.5 / ^0.3.3 so the integration works on a
fresh checkout (CI, other developers) without a sibling bcds tree.

Verified end-to-end: pnpm install resolves the registry packages,
`next dev` boots, /dashboard mounts the Grapher (12 SVGs, 17
interactive buttons), chart-type and entity-preset switching both
work, no pageerrors.
These are peer dependencies that pnpm auto-installs on our behalf:
- sass is a peer of next 16 (Next ships built-in Sass support)
- mobx and mobx-react are peers of @buildcanada/charts

Since this repo is pnpm-only (packageManager: pnpm@9.5.0) and pnpm 8+
defaults auto-install-peers to true, declaring them ourselves is
redundant — pnpm pulls them in either way. Removing keeps package.json
focused on direct dependencies and avoids version-pin drift between
us and the charts peer-dep declaration.

Verified: pnpm install resolves mobx@6.15.3 and mobx-react@7.6.0 via
peer auto-install; /dashboard mounts the Grapher cleanly (12 SVGs, 17
interactive buttons, no pageerrors).
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