Skip to content

feat(plots): show benchmark plots up to 2050 only - #1021

Merged
jacobvjk merged 2 commits into
epic/v2from
feat/plots-to-2050
Oct 26, 2026
Merged

jacobvjk merged 2 commits into
epic/v2from
feat/plots-to-2050

Conversation

@jacobvjk

Copy link
Copy Markdown
Collaborator

Closes #1010

Pathways end anywhere from 2030 to 2100 (the NGFS data runs to 2100), so benchmark plots had very different x-axes and were hard to compare. All benchmark plots, on the pathway page and the comparison page, now stop at 2050. Downloads still contain every year.

How

  • New src/utils/plotYears.ts: MAX_PLOT_YEAR = 2050 and capToPlotYears(), which drops rows after 2050.
  • PlotGrid (pathway page) and ComparisonPlots (comparison page) apply it where the rows come in, before anything else is worked out from them. That keeps everything consistent with what is drawn:
    • The comparison page's shared y-axis. It was computed from every row, so values from 2051–2100 would have stretched every compared chart's y-axis to values no longer shown.
    • Which panels appear. A series left with a single year after the cut is dropped, rather than drawn as one point.
    • The segment badges under each panel.

The download is unchanged, and says so

The download box summarises the file, e.g. "2020 → 2100", right below plots that now stop at 2050. When the plotted dataset runs past 2050, the box adds one line: "The plots on this page show years up to 2050. This download contains every year."

Checks

  • npx vitest run: 1359 passing. New tests cover:
    • the cap itself;
    • charts receiving no year after 2050, on both pages;
    • the y-axis ignoring a 2060 peak;
    • a panel with only one year left being dropped;
    • the download note.
  • npm run lint, npm run format:check: clean. tsc reports the same 203 errors as epic/v2 already does, none in the changed files.
  • Not yet checked in a browser. On this PR's preview:
    • open an NGFS pathway's Timeseries tab: the plots end at 2050, and the download box shows the note;
    • compare an NGFS pathway with one ending at 2050: the x-axes match, and the y-axes fit the visible lines.

🤖 Generated with Claude Code

Pathways end anywhere from 2030 to 2100 (NGFS), so plots side by side
had wildly different x-axes and were hard to compare.

* capToPlotYears (src/utils/plotYears.ts) drops rows after
  MAX_PLOT_YEAR = 2050. PlotGrid and ComparisonPlots apply it where
  rows enter, so everything derived from them agrees with what is drawn:
  which panels show, segment badges, and above all the comparison
  page's shared y-axis, which would otherwise stretch to values past
  2050 that no chart shows.
* Downloads are untouched and keep every year. The download box says so
  when the plotted dataset runs past 2050, since its "2020 → 2100"
  summary sits next to plots that stop at 2050.

Closes #1010

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

Copy link
Copy Markdown

Expected version change and release notes

🚨 WARNING: This PR is not expected to trigger a new version

To trigger a version bump, use at least one conventional commit message in this branch. See: https://www.conventionalcommits.org/en/v1.0.0/

@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-1021.westus2.2.azurestaticapps.net

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.

🟡 Changes recommended

Comparison entries reduced to one year still affect shared y-axis bounds despite their charts being hidden.

1 open issue
What changed in this PR

This PR addresses #1010 by limiting benchmark plot data to years through 2050 on pathway and comparison pages, while preserving complete downloads.

Changes:

  • Adds shared year-filtering helpers and applies them before deriving plot content and axis bounds.
  • Adds a download notice when the plotted dataset extends beyond 2050.
  • Adds tests for filtering, panel visibility, comparison scaling, and the download notice.
File Description
src/​utils/​plotYears.ts Defines the year cap and filtering helpers.
src/​utils/​plotYears.test.ts Tests filtering and detection of later years.
src/​pages/​PathwayDetailPage.tsx Enables the notice for the plotted dataset’s download.
src/​components/​PlotGrid.tsx Caps detail-page data before deriving panels.
src/​components/​PlotGrid.test.tsx Tests capped chart data and single-year panel removal.
src/​components/​DownloadDataset.tsx Explains that downloads retain every year.
src/​components/​DownloadDataset.test.tsx Tests conditional download notice rendering.
src/​components/​ComparisonPlots.tsx Caps comparison data before deriving chart state.
src/​components/​ComparisonPlots.test.tsx Tests year filtering and exclusion of later peaks from bounds.

Review effort: Balanced

Comment thread src/components/ComparisonPlots.tsx
Capping at 2050 can leave a comparison column with one year. PlotPanel hides that chart, but its values still set the shared y-axis bounds and flattened the charts that are shown. Skip entries without a plottable series when computing the bounds.

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

Copy link
Copy Markdown

Expected version change and release notes

🚨 WARNING: This PR is not expected to trigger a new version

To trigger a version bump, use at least one conventional commit message in this branch. See: https://www.conventionalcommits.org/en/v1.0.0/

@github-actions

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-1021.westus2.2.azurestaticapps.net

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.

🟢 Approval recommended

The cutoff consistently precedes plot calculations, downloads remain unchanged, and the previously reported shared-axis issue is fixed with regression coverage.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@jacobvjk
jacobvjk requested a review from AlexAxthelm October 26, 2026 14:58
@jacobvjk
jacobvjk merged commit fd19a42 into epic/v2 Oct 26, 2026
21 of 22 checks passed
@jacobvjk
jacobvjk deleted the feat/plots-to-2050 branch October 26, 2026 17:06
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