Skip to content

feat: sector segments in the timeseries download and benchmark plots - #976

Merged
jacobvjk merged 7 commits into
epic/v2from
feat/timeseries-segment-ui
Oct 6, 2026
Merged

jacobvjk merged 7 commits into
epic/v2from
feat/timeseries-segment-ui

Conversation

@jacobvjk

@jacobvjk jacobvjk commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #915. Stacked on #975 (#974 → #975 → this).

Download

The CSV's sector_scope column repeated one taxonomy string per metric. It is replaced by two columns read from each row's sectorSegment:

  • sector_segment: the segments, joined with "; "
  • definition_sector_segment: what each means, in the same order, next to the existing technology and metric definitions

A list is joined before quoting, so it can't spill into later columns. The CSV helpers moved to scripts/timeseries-csv.ts, with tests, because the build script runs on import. Each dataset's index summary also lists its sectorSegments.

The per-metric sectorScope is removed from timeseriesTaxonomy.ts and from common/metric.v1.json, where it was required free text.

Plots

Each panel's segment badges now come from the rows it actually draws (metric + resolved geography), ordered as the sector defines its segments.

  • A series covering several segments shows a badge for each.
  • Comparison columns read their own rows, so pathways whose series cover different segments now say so. Before, one per-metric value was repeated across every column.

Checked

  • New tests for the CSV columns, multi-segment panels and per-column segments.
  • Locally in Chrome: a segment badge on each IEA-STEPS panel (3) and each comparison column (2).
  • The built CSV header and rows look right.

🤖 Generated with Claude Code

jacobvjk and others added 2 commits October 6, 2026 10:41
The timeseries CSV's sector_scope column repeated one taxonomy string
per metric ("Power generation" for every Power metric). It is replaced
by two columns read from each row's v2 sectorSegment (#915):

- sector_segment: the segments the value covers, joined with "; "
- definition_sector_segment: what each means, in the same order, next
  to the existing technology and metric definitions

The per-metric sectorScope is removed from timeseriesTaxonomy.ts and
from common/metric.v1.json, which had it as required free text; the
rows are now the only source.

The CSV helpers move to scripts/timeseries-csv.ts so they can be tested
(the build script runs on import). A list value is now joined before
quoting, so it can never spill commas into later columns. Each
dataset's index summary also lists its sectorSegments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Benchmark plots captioned each panel with the metric's sector scope.
They now show the segments of the rows the panel actually draws (metric
and resolved geography), via plottedSegments, ordered as the sector
defines its segments:

- a series spanning several segments shows a badge for each
- comparison columns read their own rows, so two pathways whose series
  of the same metric cover different segments now say so; before, one
  per-metric value was repeated across every column

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

github-actions Bot commented Oct 6, 2026

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/

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.

Copilot review overview

🟡 Changes recommended

Segment badges can appear for one-year series that the plot considers unrenderable.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds row-level sector segments to timeseries downloads, summaries, and benchmark plot badges.

Changes:

  • Replaces metric-level sector scope with row-level segment CSV columns.
  • Displays segment badges based on each plotted series.
  • Adds segment summaries and tests.
File Description
src/​utils/​timeseriesTaxonomy.ts Removes metric-level sector scope.
src/​utils/​timeseriesSegments.ts Derives segments for plot panels.
src/​utils/​timeseriesSegments.test.ts Tests segment derivation.
src/​types/​common/​metric.v1.d.ts Updates generated metric type.
src/​schema/​common/​metric.v1.json Removes sector scope from metric schema.
src/​data/​index.gen.ts Adds dataset segment summaries.
src/​components/​PlotSelector.tsx Adds segments to plot data typing.
src/​components/​PlotSelector.test.tsx Updates plot fixtures.
src/​components/​PlotGrid.tsx Renders row-derived segment badges.
src/​components/​PlotGrid.test.tsx Tests multi-segment panels.
src/​components/​ComparisonPlots.tsx Derives segments per comparison column.
src/​components/​ComparisonPlots.test.tsx Tests per-column segments.
scripts/​timeseries-csv.ts Provides CSV and segment-column helpers.
scripts/​timeseries-csv.test.ts Tests CSV serialization.
scripts/​build-timeseries-files.ts Generates segment-aware CSVs and summaries.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils/timeseriesSegments.ts
jacobvjk and others added 2 commits October 6, 2026 12:44
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PlotPanel only draws a series with more than one distinct year; a
single-year series shows its empty state. plottedSegments counted any
matching row, so a badge could caption an empty chart (#976 review).
Both components now apply PlotPanel's own hasDataForMetricAndGeo before
reading segments, so the badge and the chart follow one rule.

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

github-actions Bot commented Oct 6, 2026

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

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://proud-glacier-0f640931e-976.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.

Copilot review overview

🟢 Approval recommended

The implementation consistently uses row-level segments and includes focused regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

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

github-actions Bot commented Oct 6, 2026

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

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

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

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

github-actions Bot commented Oct 6, 2026

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

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

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

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

github-actions Bot commented Oct 6, 2026

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

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

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

Base automatically changed from feat/timeseries-import to epic/v2 October 6, 2026 16:48
@jacobvjk
jacobvjk merged commit 7fc1c5f into epic/v2 Oct 6, 2026
10 checks passed
@jacobvjk
jacobvjk deleted the feat/timeseries-segment-ui branch October 6, 2026 16:49
@github-actions github-actions Bot mentioned this pull request Oct 6, 2026
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