Add interactive dashboard with Build Canada charts library#15
Open
xrendan wants to merge 8 commits into
Open
Conversation
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).
Replaces the life-expectancy demo at /dashboard with a real KPI browser: - /dashboard — index of jurisdictions and their organizations - /dashboard/[jurisdiction]/[org] — per-org dashboard showing every numeric measure with a Grapher chart (actual + target series across the available years), grouped by service category in a sidebar Adds src/lib/api/kpis.ts with typed fetchers for jurisdictions, organizations, measures, and facts (auto-paginating). The KPI endpoints live under /api/v1/kpis on the york_factory API (see ../york_factory/docs/api/kpis). Reads are unauthenticated and revalidated server-side every 10 minutes.
Restructures the per-org dashboard so each KPI measure is a separately shareable, SEO-friendly route: /dashboard/[jurisdiction]/[org]/[measure] - New [org]/layout.tsx owns the org header and the sidebar of measures (Link-based, active state via usePathname). - [org]/page.tsx becomes an overview: cards for each measure showing the latest actual value with a link to the measure's chart page. - New [org]/[measure]/page.tsx fetches the measure (via getMeasure for description + lineages) and its facts, then renders a single Grapher chart with line/bar toggle. Adds listFactsForMeasure and getMeasure fetchers to src/lib/api/kpis.ts.
Lists every source document the measure's citations come from (PDF title, publication date, fiscal year, years covered, page numbers, and value types contributed). Documents are unique per row and sorted by publication date descending. Adds listCitationsForMeasure to src/lib/api/kpis.ts.
Replaces the standalone Sources panel with in-chart citation rendering on the @buildcanada/charts Grapher: - variable metadata.origins[] — one entry per source document (title, producer, urlMain, datePublished, citationFull with page numbers). Grapher's Sources tab renders these natively. - GrapherState.sourceDesc — compact "Data source:" footer line. - GrapherState.originUrl — clickable footer link to the most recent source PDF.
Joining raw doc titles with "; " produced noisy footers like "Transportation Services - Operating Budget; Operating Budget". For measures backed by multiple source documents, the footer line now reads "<organization> · N source documents · FY <range>" — individual titles still live in the Sources tab.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new interactive dashboard page that showcases the
@buildcanada/chartslibrary's Grapher component with life expectancy data visualization capabilities.Key Changes
src/app/dashboard/page.tsx): Server component that sets up metadata and imports the Build Canada charts stylesheetsrc/app/dashboard/Dashboard.tsx): Interactive client component featuring:src/app/dashboard/DashboardClient.tsx): Client-side dynamic import with SSR disabled and loading skeleton for better UX@buildcanada/charts,@buildcanada/colours,@buildcanada/components,mobx,mobx-react, andsassto support the charting libraryImplementation Details
useState,useMemo,useEffect) to manage chart type, entity selection, and responsive sizinghttps://claude.ai/code/session_01H5n1EL6QDosMXGTS8UndR9