Skip to content

fix(app): dedupe Y-axis tick labels on stacked time charts - #3699

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
cursor/stacked-chart-duplicate-y-ticks-108a
Nov 17, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
cursor/stacked-chart-duplicate-y-ticks-108a

Conversation

@MikeShi42

Copy link
Copy Markdown
Contributor

Summary

Stacked bar and stacked line charts could show the same Y-axis label twice. With a "Number" format at 0 decimals and a stack that reaches 2000, the axis rendered 0, 500, 1k, 2k, 2k, because 1500 rounds to "2k".

Line charts already avoid this: computeYAxisBounds picks nice ticks and escalates precision when two labels collide. Stacked charts returned early from it and left ticks to Recharts, because the function only scanned per-series values, not stack heights. The label formatter then rounded Recharts' ticks with nothing checking for collisions.

This PR:

  • Adds scanStackedYAxisValueRange, which computes the axis extent from each row's running sums. This matches how Recharts stacks with its default stackOffset="none" (each series sits on the previous one's top, null counts as 0, zero baseline included).
  • Sends stacked charts through the same zero-pinned tick path the default line chart uses, so they get the same distinct-label handling. Stacked charts stay pinned at zero whatever the fit-to-data setting, which is documented as line-only.
  • Leaves stacked charts with a reference line on Recharts' auto ticks, as line charts already do in that branch. That path can still collide, and this PR doesn't change it.

Screenshots or video

Same dashboard tile (raw SQL, stacked bar, 1200 + 800 per bucket, Number format, 0 decimals).

Before After
Before: 0, 500, 1k, 2k, 2k After: 0, 500, 1k, 1.5k, 2k

How to reproduce

Starting point: yarn app:dev:local connected to the demo server (onboarding → "Connect to Demo Server").

On main:

  1. Go to Dashboards, create a dashboard, and add a tile.
  2. Switch the tile to raw SQL (time series) and enter:
    SELECT toStartOfInterval(now() - INTERVAL number MINUTE, INTERVAL {intervalSeconds:Int64} SECOND) AS ts, any(toFloat64(1200)) AS a, any(toFloat64(800)) AS b FROM numbers(60) GROUP BY ts ORDER BY ts
  3. Keep display type as stacked bar. In display settings, set the number format to "Number" with 0 decimals.
  4. Set the time range to the last hour and save the tile. The Y axis reads 0, 500, 1k, 2k, 2k.

On this branch:

  1. Same steps. The Y axis reads 0, 500, 1k, 1.5k, 2k.

How to test on Vercel preview

Preview routes: /dashboards

Steps:

  1. Create a new dashboard and click "Add" to add a tile.
  2. Switch the tile to raw SQL time series and enter the SQL from "How to reproduce" above.
  3. Choose the stacked bar display type, open display settings, set number format to "Number" with 0 decimals, and save the tile with a "last 1 hour" range.
  4. Verify the Y-axis labels are 0, 500, 1k, 1.5k, 2k, with no label repeated.

References

Open in Web Open in Cursor 

Stacked bar and stacked line charts bypassed computeYAxisBounds and let
Recharts pick ticks, so a 2000-high stack at 0 decimals rendered
0/500/1k/2k/2k. Scan the stacked running sums (matching Recharts'
stackOffset=none) and route stacked charts through the same zero-pinned
nice-tick path line charts use, which escalates precision on collisions.

Co-authored-by: Mike Shi <mike@hyperdx.io>
@MikeShi42
MikeShi42 requested a review from a team as a code owner November 17, 2026 21:00
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 17, 2026 10:51pm UTC
hyperdx-storybook Ready Ready Preview Nov 17, 2026 10:51pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 03883d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 1
  • Production lines changed: 43 (+ 135 in test files, excluded from tier calculation)
  • Branch: cursor/stacked-chart-duplicate-y-ticks-108a
  • Author: MikeShi42

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 108 in total (1.17%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

✅ No issues found.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a focused, well-scoped fix. scanStackedYAxisValueRange correctly mirrors Recharts' stackOffset="none" geometry (plain per-row running sums, null/non-numeric treated as 0, zero baseline pinned via Math.min(min, 0)/Math.max(max, 0)), and the mixed-sign case is handled by tracking every intermediate running sum rather than only the final total. The rendered <Bar>/<Area> series and the summed domain both derive from the same visibleLineData (selection- and HARD_LINES_LIMIT-filtered), so the computed axis extent stays consistent with what is drawn, including under series selection. The reference-line branch still defers to Recharts, and the empty-range (max === -Infinity) early return is preserved. Tests cover both StackedBar and StackedLine, the 1.5k-rounds-to-2k dedup regression, the fit-to-data-stays-zero-pinned behavior, selection on/off, and the reference-line passthrough. The changeset format and '@hyperdx/app': patch scope match repo convention.

No behavior-changing defects, no missing-test gaps for the new behavior, and no project-standards violations were found in the diff.

Notes (non-blocking)

  • The intentional behavior change — stacked charts now ignore fitYAxisToData and stay zero-pinned — is documented in code comments and asserted by a dedicated test, so it will not silently surprise a future reader.
  • scanStackedYAxisValueRange and scanYAxisValueRange share loop structure; a shared helper is possible but the duplication is small and each reads clearly on its own, so no change is warranted.

Reviewers (6): correctness, testing, maintainability, kieran-typescript, project-standards, previous-comments (prior comments were automated Vercel/changeset-bot output only — no substantive feedback to verify).

Testing gaps: none substantive — new behavior is covered for both stacked display types, selection states, the rounding-collision regression, and the reference-line and fit-to-data branches.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 466 passed • 1 skipped • 1186s

Status Count
✅ Passed 466
❌ Failed 0
⚠️ Flaky 2
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

if (isStacked || (!hasSelection && !shouldFitYAxis)) {
// A fully numeric domain skips Recharts' own nice rounding, and a
// reference line can extend it further - defer to Recharts entirely.
if (referenceLineValues.length > 0) {

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.

/nit Could this extend the domain to the reference line instead of handing ticks back to Recharts?

A stacked tile with an alert threshold still goes through here, so does it keep showing 2k, 2k? The fit-to-data branch further down already widens its bounds with referenceLineValues before picking ticks. Would the same work here?

const lowerBound = cleanNumber(Math.min(0, min, ...referenceLineValues));
const upperBound = cleanNumber(
  Math.max(max + Math.abs(max) * 0.05, ...referenceLineValues),
);

@kodiakhq
kodiakhq Bot merged commit 3c8794f into main Nov 17, 2026
28 checks passed
@kodiakhq
kodiakhq Bot deleted the cursor/stacked-chart-duplicate-y-ticks-108a branch November 17, 2026 22:56

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 03883d99 Deployed Nov 17, 2026 by vercel[bot]
Preview – hyperdx-storybook — 03883d99 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants