Skip to content

Upgrade @buildcanada/charts 0.3.9 -> 1.1.0 #96

Description

@buildcanada-fabro

Why this is a breaking migration

The app currently has @buildcanada/charts 0.3.9 for dashboard/State of the Nation charts and installs 1.1.0 separately as the @buildcanada/charts-inline alias for poll charts. The 1.0.0 release replaced the legacy Grapher/MobX library with charts2; this is a new API, not a compatible version bump. The old Grapher, GrapherState, Bounds, and legacy table helpers used by the app are not part of the v1 API. V1 uses chart definitions and manifest/row datasets with the Chart renderer and a pure layout core. The v1 package also drops the old MobX peer dependencies.

Files to migrate or review

Dependency and lockfile:

  • package.json
  • pnpm-lock.yaml

Legacy Grapher renderers to port:

  • src/app/dashboard/[jurisdiction]/[org]/[measure]/MeasureChart.tsx
  • src/app/state-of-the-nation/IndicatorChart.tsx
  • src/app/state-of-the-nation/CombinedSectionChart.tsx
  • src/app/state-of-the-nation/StateChartPlot.tsx
  • src/app/state-of-the-nation/canvas/OverlayIndexedChart.tsx

Existing stylesheet imports to visually verify against the v1 stylesheet:

  • src/app/dashboard/[jurisdiction]/[org]/layout.tsx
  • src/app/state-of-the-nation/page.tsx
  • src/app/state-of-the-nation/[section]/page.tsx
  • src/app/state-of-the-nation/canvas/page.tsx

The existing v1 inline-chart integration can move from the alias to the canonical package import as part of consolidating dependencies:

  • src/components/content/InlineChart.tsx
  • src/lib/charts/inline-chart.ts
  • src/lib/charts/inline-chart.test.ts

Update the split-version explanation in docs/polls/README.md. During the port, also review Grapher-specific formatting/sizing and capability assumptions in src/app/state-of-the-nation/units.ts, src/app/state-of-the-nation/useChartSize.ts, src/app/state-of-the-nation/StateChart.tsx, src/app/state-of-the-nation/canvas/CanvasClient.tsx, and src/app/state-of-the-nation/canvas/OverlayChart.tsx.

Migration steps

  1. Upgrade the canonical @buildcanada/charts dependency to 1.1.0, remove the temporary charts-inline alias if all consumers move to the canonical import, and regenerate pnpm-lock.yaml. Check whether MobX dependencies are still needed elsewhere before removing them.
  2. Replace each Grapher/GrapherState construction and with v1 data and definition construction (for example, parseManifest/buildDataset/parseDefinition from @buildcanada/charts/core) and render with .
  3. Translate the existing entity/year/value data and Grapher metadata to manifest columns and rows. Preserve the current line/bar choices, date-vs-annual axes, series selection/colours, number and unit formatting, and compact/uncaptioned layouts using v1 definitions, themes, and renderer options.
  4. Retarget inline-chart imports and stylesheet imports as appropriate; update docs/polls/README.md so it no longer says dashboard code stays on 0.3.x.
  5. Run typecheck/build and poll-chart tests, then visually check KPI, indicator, combined, State of the Nation, indexed-overlay, and inline poll charts for layout, axes, labels, colours, and interaction regressions.

Upstream references

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions