Skip to content

feat(studio): Comparison Line Chart common component - #1244

Merged
steramae-nvidia merged 4 commits into
mainfrom
steramae/comparison-line-chart
Aug 12, 2026
Merged

feat(studio): Comparison Line Chart common component#1244
steramae-nvidia merged 4 commits into
mainfrom
steramae/comparison-line-chart

Conversation

@steramae-nvidia

@steramae-nvidia steramae-nvidia commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-08-11 at 2 52 25 PM Screenshot 2026-08-11 at 2 52 06 PM

feat(studio): Comparison Line Chart common component

Signed-off-by: Sean Teramae steramae@nvidia.com

lock file

Signed-off-by: Sean Teramae steramae@nvidia.com

Summary

Related Issue

Changes

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with documentation updates
  • Documentation only
  • Contributor tooling or automation
  • CI, build, or test infrastructure

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification:

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Targeted validation:

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a reusable comparison line chart with configurable axes, series, legends, tooltips, annotations, reference lines, and formatting.
    • Added interactive series visibility, hover highlighting, and dashed reference series.
    • Added loading and empty states.
    • Added support for time, numeric, and category-based comparisons.
  • Tests

    • Added comprehensive coverage for rendering, interactions, formatting, annotations, and edge cases.
  • Chores

    • Excluded generated Storybook output from version control.

@steramae-nvidia
steramae-nvidia requested review from a team as code owners August 11, 2026 21:51
@steramae-nvidia

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

@github-actions github-actions Bot added the feat label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: adc9276c-d0b1-42e9-9720-b4cc4971e9ac

📥 Commits

Reviewing files that changed from the base of the PR and between 51531d4 and 80eae8c.

📒 Files selected for processing (1)
  • web/.gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/.gitignore

📝 Walkthrough

Walkthrough

Adds a reusable ComparisonLineChart with typed series, axis handling, legends, tooltips, annotations, reference lines, loading and empty states. It also adds utilities, tests, Storybook stories, Recharts peer dependency wiring, and generated-output ignores.

Changes

Comparison line chart

Layer / File(s) Summary
Chart contracts and rendering primitives
web/packages/common/package.json, web/packages/common/src/components/ComparisonLineChart/types.ts, consts.ts, chartFrame.ts, ComparisonLegend.tsx, ComparisonTooltip.tsx, ComparisonAnnotationLabel.tsx, ComparisonChartHeader.tsx, ComparisonLineChartEmpty.tsx, ComparisonLineChartSkeleton.tsx
Defines chart types and styling constants. Adds reusable legend, tooltip, annotation, header, empty-state, loading, and chart-frame components.
Chart data and annotation utilities
web/packages/common/src/components/ComparisonLineChart/utils.ts
Transforms series data into chart rows, infers axis types, validates plottable data, resolves annotations, and formats values.
Chart rendering and public wiring
web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx, useComparisonChartModel.ts, index.tsx, web/packages/common/src/components/index.ts
Implements chart state, rendering, legend interaction, axes, tooltips, reference lines, annotations, series styling, loading and empty branches, and public exports.
Chart validation and examples
web/packages/common/src/components/ComparisonLineChart/index.test.tsx, ComparisonLineChart.stories.tsx, web/.gitignore
Adds component and utility tests. Adds stories for chart variants, states, annotations, and platform comparisons. Ignores generated Storybook output.

Sequence Diagram(s)

sequenceDiagram
  participant ComparisonLineChart
  participant useComparisonChartModel
  participant ComparisonLegend
  participant Recharts
  ComparisonLineChart->>useComparisonChartModel: Build chart rows and resolve chart state
  ComparisonLineChart->>ComparisonLegend: Render legend items and callbacks
  ComparisonLineChart->>Recharts: Render axes, lines, reference lines, annotations, and tooltip
  ComparisonLegend->>ComparisonLineChart: Toggle or hover a series
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the addition of the shared Studio comparison line chart component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch steramae/comparison-line-chart

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
web/packages/common/src/components/ComparisonLineChart/types.ts (1)

14-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make chart input contracts readonly.

The components and utilities do not mutate these inputs. Mark immutable properties and collections as readonly. Update utility parameters to accept readonly collections.

  • web/packages/common/src/components/ComparisonLineChart/types.ts#L14-L25: make ComparisonSeries immutable, including data.
  • web/packages/common/src/components/ComparisonLineChart/types.ts#L59-L90: make chart input collections and immutable properties readonly.
  • web/packages/common/src/components/ComparisonLineChart/ComparisonLegend.tsx#L8-L22: accept readonly legend items.
  • web/packages/common/src/components/ComparisonLineChart/utils.ts#L21-L25: accept a readonly x axis.
  • web/packages/common/src/components/ComparisonLineChart/utils.ts#L36-L39: accept readonly series and x-axis collections.
  • web/packages/common/src/components/ComparisonLineChart/utils.ts#L62-L62: accept a readonly x axis.
  • web/packages/common/src/components/ComparisonLineChart/utils.ts#L88-L91: accept readonly series and x-axis collections.
  • web/packages/common/src/components/ComparisonLineChart/utils.ts#L122-L124: accept readonly series and x-axis collections.

As per coding guidelines, use readonly for immutable properties.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/common/src/components/ComparisonLineChart/types.ts` around lines
14 - 25, Make the ComparisonLineChart input contracts readonly: update
ComparisonSeries and the chart input types in
web/packages/common/src/components/ComparisonLineChart/types.ts (lines 14-25 and
59-90), accept readonly legend items in ComparisonLegend.tsx (lines 8-22), and
change the utility parameters in utils.ts (lines 21-25, 36-39, 62, 88-91, and
122-124) to accept readonly x-axis and series collections, including readonly
data and immutable properties.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/packages/common/src/components/ComparisonLineChart/index.tsx`:
- Around line 101-109: Move the onVisibleSeriesChange invocation out of the
setHiddenIds functional updater in the comparison chart toggle handler,
computing the next hidden IDs once before updating state and notifying the
parent once per toggle. Preserve the existing visible-series filtering, and add
a Strict Mode test covering a toggle with exactly one callback notification.

In `@web/packages/common/src/components/ComparisonLineChart/utils.ts`:
- Around line 36-45: Validate all series IDs before constructing rows in
buildChartRows: reject the reserved "x" ID and any duplicate IDs, before
assigning values onto ComparisonChartRow. Preserve the existing row-building
behavior for valid, unique series IDs.
- Around line 121-124: Update hasPlottableData to inspect only series values
corresponding to xAxis indices, matching the points emitted by buildChartRows.
Limit each series scan to xAxis.length (or reject mismatched lengths) so
trailing values cannot make an otherwise empty chart appear plottable.

---

Nitpick comments:
In `@web/packages/common/src/components/ComparisonLineChart/types.ts`:
- Around line 14-25: Make the ComparisonLineChart input contracts readonly:
update ComparisonSeries and the chart input types in
web/packages/common/src/components/ComparisonLineChart/types.ts (lines 14-25 and
59-90), accept readonly legend items in ComparisonLegend.tsx (lines 8-22), and
change the utility parameters in utils.ts (lines 21-25, 36-39, 62, 88-91, and
122-124) to accept readonly x-axis and series collections, including readonly
data and immutable properties.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e1aae3b0-e505-457d-b6be-6dc2b2ca475f

📥 Commits

Reviewing files that changed from the base of the PR and between d5e9e4e and d4d0bfe.

⛔ Files ignored due to path filters (1)
  • web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • web/.gitignore
  • web/packages/common/package.json
  • web/packages/common/src/components/ComparisonLineChart/ComparisonAnnotationLabel.tsx
  • web/packages/common/src/components/ComparisonLineChart/ComparisonLegend.tsx
  • web/packages/common/src/components/ComparisonLineChart/ComparisonLineChart.stories.tsx
  • web/packages/common/src/components/ComparisonLineChart/ComparisonLineChartEmpty.tsx
  • web/packages/common/src/components/ComparisonLineChart/ComparisonLineChartSkeleton.tsx
  • web/packages/common/src/components/ComparisonLineChart/ComparisonTooltip.tsx
  • web/packages/common/src/components/ComparisonLineChart/consts.ts
  • web/packages/common/src/components/ComparisonLineChart/index.test.tsx
  • web/packages/common/src/components/ComparisonLineChart/index.tsx
  • web/packages/common/src/components/ComparisonLineChart/types.ts
  • web/packages/common/src/components/ComparisonLineChart/utils.ts
  • web/packages/common/src/components/index.ts

Comment thread web/packages/common/src/components/ComparisonLineChart/index.tsx Outdated
Comment thread web/packages/common/src/components/ComparisonLineChart/utils.ts
Comment thread web/packages/common/src/components/ComparisonLineChart/utils.ts Outdated
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 32016/40717 78.6% 63.5%
Integration Tests 18566/38643 48.0% 20.8%

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
web/packages/common/src/components/ComparisonLineChart/index.tsx (3)

156-157: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve className during loading.

The loading branch drops the public className. The ready and empty branches apply it to the outer Stack, so the loading state can lose consumer styling or change layout. Wrap the skeleton in the same outer container or pass className to it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/common/src/components/ComparisonLineChart/index.tsx` around
lines 156 - 157, Update the loading branch of ComparisonLineChart to preserve
the public className, matching the ready and empty states by either applying it
to an equivalent outer Stack or passing it to ComparisonLineChartSkeleton. Keep
the existing loading skeleton and height behavior unchanged.

236-236: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use unique keys for overlay entries.

The keys use coordinates and labels only. Two reference lines with the same y and label, or two annotations with the same x and label, produce duplicate React keys. Use a stable unique ID from each item, with an index fallback only when the contract has no ID.

Also applies to: 249-249

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/common/src/components/ComparisonLineChart/index.tsx` at line
236, Update the overlay entry keys in the comparison chart render near the
reference-line and annotation entries to use each item’s stable unique ID,
falling back to the mapped index only when no ID exists. Apply this to both the
`ref-` and annotation key paths, replacing coordinate-and-label-only keys while
preserving the existing prefixes.

279-279: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear hoveredId when hiding a series.

If the user hides the currently hovered series, hoveredId still names the hidden series. This fades every remaining line until pointer leave. Clear hoveredId when hiding that ID, or apply fading only when the hovered ID remains visible. Add a regression test for this interaction.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/common/src/components/ComparisonLineChart/index.tsx` at line
279, Update the series-hiding logic in ComparisonLineChart so hiding the series
identified by hoveredId clears that state, or ensure fading only applies when
hoveredId still refers to a visible series. Preserve hover fading for visible
series and add a regression test covering hiding the currently hovered series.
🧹 Nitpick comments (1)
web/packages/common/src/components/ComparisonLineChart/index.tsx (1)

52-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare the public component return type.

ComparisonLineChart is a public API, but its return type is inferred. Add the repository’s preferred explicit React return type.

As per coding guidelines: use explicit return types for public APIs and complex functions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/common/src/components/ComparisonLineChart/index.tsx` around
lines 52 - 77, Update the public ComparisonLineChart component declaration to
include the repository-preferred explicit React return type, while preserving
its existing props, defaults, and rendering behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@web/packages/common/src/components/ComparisonLineChart/index.tsx`:
- Around line 156-157: Update the loading branch of ComparisonLineChart to
preserve the public className, matching the ready and empty states by either
applying it to an equivalent outer Stack or passing it to
ComparisonLineChartSkeleton. Keep the existing loading skeleton and height
behavior unchanged.
- Line 236: Update the overlay entry keys in the comparison chart render near
the reference-line and annotation entries to use each item’s stable unique ID,
falling back to the mapped index only when no ID exists. Apply this to both the
`ref-` and annotation key paths, replacing coordinate-and-label-only keys while
preserving the existing prefixes.
- Line 279: Update the series-hiding logic in ComparisonLineChart so hiding the
series identified by hoveredId clears that state, or ensure fading only applies
when hoveredId still refers to a visible series. Preserve hover fading for
visible series and add a regression test covering hiding the currently hovered
series.

---

Nitpick comments:
In `@web/packages/common/src/components/ComparisonLineChart/index.tsx`:
- Around line 52-77: Update the public ComparisonLineChart component declaration
to include the repository-preferred explicit React return type, while preserving
its existing props, defaults, and rendering behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: df361643-ed7d-462b-a487-932441ef0dc3

📥 Commits

Reviewing files that changed from the base of the PR and between d4d0bfe and d467212.

📒 Files selected for processing (3)
  • web/packages/common/src/components/ComparisonLineChart/index.test.tsx
  • web/packages/common/src/components/ComparisonLineChart/index.tsx
  • web/packages/common/src/components/ComparisonLineChart/utils.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/packages/common/src/components/ComparisonLineChart/index.test.tsx
  • web/packages/common/src/components/ComparisonLineChart/utils.ts

Comment thread web/packages/common/src/components/ComparisonLineChart/index.tsx
@steramae-nvidia
steramae-nvidia force-pushed the steramae/comparison-line-chart branch from d467212 to 51531d4 Compare August 12, 2026 17:11

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
web/packages/common/src/components/ComparisonLineChart/ComparisonChartHeader.tsx (1)

7-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Mark immutable contract fields as readonly.

  • web/packages/common/src/components/ComparisonLineChart/ComparisonChartHeader.tsx#L7-L10: mark Props.title and Props.legend as readonly.
  • web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx#L19-L21: mark ColoredSeries.resolvedColor as readonly.
  • web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx#L64-L69: mark SeriesLineOptions fields as readonly.

As per coding guidelines, “Use readonly for immutable properties.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@web/packages/common/src/components/ComparisonLineChart/ComparisonChartHeader.tsx`
around lines 7 - 10, Mark the immutable contract fields as readonly: Props.title
and Props.legend in
web/packages/common/src/components/ComparisonLineChart/ComparisonChartHeader.tsx
(lines 7-10), ColoredSeries.resolvedColor in
web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx (lines
19-21), and every field of SeriesLineOptions in
web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx (lines
64-69).

Source: Coding guidelines

web/packages/common/src/components/ComparisonLineChart/chartFrame.ts (1)

11-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare return types for exported APIs.

  • web/packages/common/src/components/ComparisonLineChart/chartFrame.ts#L11-L16: declare the structural margin return type.
  • web/packages/common/src/components/ComparisonLineChart/index.tsx#L39-L64: declare the component return type.
  • web/packages/common/src/components/ComparisonLineChart/useComparisonChartModel.ts#L39-L48: declare a model interface and use it as the hook return type.

As per coding guidelines, “Use explicit return types for public APIs and complex functions.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/common/src/components/ComparisonLineChart/chartFrame.ts` around
lines 11 - 16, Declare explicit public return types for all three APIs: in
web/packages/common/src/components/ComparisonLineChart/chartFrame.ts lines
11-16, add a structural margin return type to chartMargin; in
web/packages/common/src/components/ComparisonLineChart/index.tsx lines 39-64,
annotate the component return type; and in
web/packages/common/src/components/ComparisonLineChart/useComparisonChartModel.ts
lines 39-48, define a model interface and use it as the hook return type.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@web/packages/common/src/components/ComparisonLineChart/chartFrame.ts`:
- Around line 11-16: Declare explicit public return types for all three APIs: in
web/packages/common/src/components/ComparisonLineChart/chartFrame.ts lines
11-16, add a structural margin return type to chartMargin; in
web/packages/common/src/components/ComparisonLineChart/index.tsx lines 39-64,
annotate the component return type; and in
web/packages/common/src/components/ComparisonLineChart/useComparisonChartModel.ts
lines 39-48, define a model interface and use it as the hook return type.

In
`@web/packages/common/src/components/ComparisonLineChart/ComparisonChartHeader.tsx`:
- Around line 7-10: Mark the immutable contract fields as readonly: Props.title
and Props.legend in
web/packages/common/src/components/ComparisonLineChart/ComparisonChartHeader.tsx
(lines 7-10), ColoredSeries.resolvedColor in
web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx (lines
19-21), and every field of SeriesLineOptions in
web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx (lines
64-69).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ee72bbf2-577c-4e96-b4d5-0d345e5fe321

📥 Commits

Reviewing files that changed from the base of the PR and between d467212 and 51531d4.

📒 Files selected for processing (6)
  • web/packages/common/src/components/ComparisonLineChart/ComparisonChartHeader.tsx
  • web/packages/common/src/components/ComparisonLineChart/ComparisonLineChartEmpty.tsx
  • web/packages/common/src/components/ComparisonLineChart/chartFrame.ts
  • web/packages/common/src/components/ComparisonLineChart/chartLayers.tsx
  • web/packages/common/src/components/ComparisonLineChart/index.tsx
  • web/packages/common/src/components/ComparisonLineChart/useComparisonChartModel.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/packages/common/src/components/ComparisonLineChart/ComparisonLineChartEmpty.tsx

Signed-off-by: Sean Teramae <steramae@nvidia.com>
Signed-off-by: Sean Teramae <steramae@nvidia.com>
Signed-off-by: Sean Teramae <steramae@nvidia.com>
Signed-off-by: Sean Teramae <steramae@nvidia.com>
@steramae-nvidia
steramae-nvidia force-pushed the steramae/comparison-line-chart branch from 51531d4 to 80eae8c Compare August 12, 2026 17:15
@steramae-nvidia
steramae-nvidia added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit 48cf7da Aug 12, 2026
99 of 146 checks passed
@steramae-nvidia
steramae-nvidia deleted the steramae/comparison-line-chart branch August 12, 2026 21:39
@coderabbitai coderabbitai Bot mentioned this pull request Aug 14, 2026
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants