Skip to content

feat: SW-1891 add xTickText prop for categorical x-axis labels#147

Open
owilliams-tetrascience wants to merge 2 commits into
mainfrom
claude/angry-greider-19e0be
Open

feat: SW-1891 add xTickText prop for categorical x-axis labels#147
owilliams-tetrascience wants to merge 2 commits into
mainfrom
claude/angry-greider-19e0be

Conversation

@owilliams-tetrascience

@owilliams-tetrascience owilliams-tetrascience commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional xTickText?: string[] prop to AreaGraph, BarGraph, and LineGraph so consumers can display categorical x-axis labels (days of the week, instrument names, dates, …) instead of raw integer indices.

These charts previously accepted only numeric x values and forced the x-axis ticks to those literal numbers (tickmode: "array" + tickvals). Real dashboard tiles — e.g. a "Pipeline runs by status" chart that should show Mon–Sun — rendered 0 1 2 3 4 5 6 because the consumer had to pre-convert categorical labels to integers.

When xTickText is provided, the numeric x values still drive bar/line/area positioning, but the rendered tick labels match xTickText in order via Plotly's tickvals + ticktext:

<BarGraph
  dataSeries={[{ name: "Success", x: [0,1,2,3,4,5,6], y: [...], color: "#29A634" }]}
  xTickText={["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]}
  variant="group"
/>

Implements SW-1891.

Notes for reviewers

  • AreaGraph computes its x-ticks via a nice-step algorithm that wouldn't align with categorical labels, so when xTickText is set it switches tickvals to the actual unique data x-positions. Bar/Line already keyed ticks off the data x-values.
  • No behavior change when the prop is omitted — numeric-x rendering is byte-for-byte identical, and all existing numeric-x stories pass unchanged.
  • New stories leave parameters.zephyr.testCaseId empty per repo convention; the sync-storybook-zephyr workflow will generate the IDs (apply the zephyr_sync label).

Type of Change

  • Feature (new functionality)
  • Bug fix
  • Refactor
  • Documentation
  • Chore (build, CI, dependencies)
  • Breaking change

Checklist

  • yarn lint passes
  • yarn build passes
  • yarn test:all passes (656 storybook + 548 unit)
  • Storybook stories added/updated
  • Code coverage remains the same or increased

Testing

A new "Categorical X Labels" Storybook story was added to each of AreaGraph, BarGraph, and LineGraph, each with a play-function test asserting the x-axis renders ["Mon" … "Sun"] rather than integer indices.

Zephyr test case IDs to be generated via sync-storybook-zephyr (IDs intentionally left empty on the new stories).

Verification

  • Deploys to preview environment for manual verification
  • All CI/E2E checks pass

🤖 Generated with Claude Code

AreaGraph, BarGraph, and LineGraph only accepted numeric x-values and
forced the x-axis ticks to those literal numbers, so common dashboard
cases (days of week, instrument names, dates) rendered as 0 1 2 … and
consumers had to pre-convert categorical data to integers.

Add an optional xTickText?: string[] prop to all three. When provided,
the numeric x values still drive bar/line/area positioning while the
rendered tick labels match xTickText in order via Plotly tickvals +
ticktext. AreaGraph additionally switches tickvals from its nice-step
values to the actual data x-positions when xTickText is set, so labels
align with the data. Numeric-x behavior is unchanged when the prop is
omitted.

Adds a "Categorical X Labels" Storybook story per chart with a play
test asserting the axis renders the categorical labels.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 19:59
@owilliams-tetrascience owilliams-tetrascience requested review from a team as code owners June 23, 2026 19:59
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ts-lib-ui-kit-storybook Ready Ready Preview, Comment Jun 23, 2026 8:10pm

Request Review

@owilliams-tetrascience owilliams-tetrascience changed the title SW-1891 Add xTickText prop for categorical x-axis labels feat: SW-1891 add xTickText prop for categorical x-axis labels Jun 23, 2026

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.

Pull request overview

Adds an optional xTickText?: string[] prop to the Plotly-based AreaGraph, BarGraph, and LineGraph components so consumers can keep numeric x positions while rendering categorical x-axis tick labels (e.g., weekdays).

Changes:

  • Added xTickText?: string[] to AreaGraph/BarGraph/LineGraph props and wired it into Plotly xaxis.ticktext.
  • Updated AreaGraph tick positioning logic for categorical labels to use data-derived x positions instead of “nice-step” ticks.
  • Added new “Categorical X Labels” Storybook stories (with play assertions on x-axis tick labels) for AreaGraph, BarGraph, and LineGraph.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/components/charts/LineGraph/LineGraph.tsx Adds xTickText prop and uses it for Plotly x-axis tick labels.
src/components/charts/LineGraph/LineGraph.stories.tsx Adds a categorical-label story + play assertions for LineGraph.
src/components/charts/BarGraph/BarGraph.tsx Adds xTickText prop and conditionally sets Plotly ticktext.
src/components/charts/BarGraph/BarGraph.stories.tsx Adds a categorical-label story + play assertions for BarGraph.
src/components/charts/AreaGraph/AreaGraph.tsx Adds xTickText prop; switches categorical tickvals to data-derived x positions.
src/components/charts/AreaGraph/AreaGraph.stories.tsx Adds a categorical-label story + play assertions for AreaGraph.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/charts/AreaGraph/AreaGraph.tsx
Comment thread src/components/charts/AreaGraph/AreaGraph.tsx Outdated
Comment thread src/components/charts/BarGraph/BarGraph.tsx Outdated
Comment thread src/components/charts/LineGraph/LineGraph.tsx Outdated
Comment thread src/components/charts/AreaGraph/AreaGraph.stories.tsx Outdated
Comment thread src/components/charts/BarGraph/BarGraph.stories.tsx Outdated
Comment thread src/components/charts/LineGraph/LineGraph.stories.tsx Outdated
Address review feedback on the xTickText feature:
- Sort the unique x-positions ascending so categorical labels map
  deterministically to x regardless of per-series ordering.
- Only apply xTickText when its length matches the tick positions 1:1;
  otherwise fall back to numeric ticks instead of silently mis-labeling.
- Use the standard sync-storybook-zephyr marker comment above the empty
  testCaseId placeholders in the new stories.

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

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 94.75% (🎯 83%)
⬆️ +0.01%
20639 / 21782
🟢 Statements 94.75% (🎯 83%)
⬆️ +0.01%
20639 / 21782
🟢 Functions 93.58% (🎯 74%)
🟰 ±0%
919 / 982
🟢 Branches 88.79% (🎯 81%)
⬆️ +0.05%
3787 / 4265
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/components/charts/AreaGraph/AreaGraph.tsx 99.63%
⬆️ +0.01%
84.09%
⬆️ +4.09%
100%
🟰 ±0%
99.63%
⬆️ +0.01%
61
src/components/charts/BarGraph/BarGraph.tsx 99.51%
⬆️ +0.01%
86.2%
⬆️ +2.87%
100%
🟰 ±0%
99.51%
⬆️ +0.01%
124
src/components/charts/LineGraph/LineGraph.tsx 96.86%
⬆️ +0.03%
84.84%
⬆️ +2.09%
100%
🟰 ±0%
96.86%
⬆️ +0.03%
323-329
Generated in workflow #816 for commit bd1c361 by the Vitest Coverage Report Action

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