Repository navigation
fix(app): dedupe Y-axis tick labels on stacked time charts - #3699
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 03883d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review✅ No issues found. |
Deep Review✅ No critical issues found. This is a focused, well-scoped fix. 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)
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 |
E2E Test Results✅ All tests passed • 466 passed • 1 skipped • 1186s
Tests ran across 4 shards in parallel. |
| 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) { |
There was a problem hiding this comment.
/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),
);
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:
computeYAxisBoundspicks 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:
scanStackedYAxisValueRange, which computes the axis extent from each row's running sums. This matches how Recharts stacks with its defaultstackOffset="none"(each series sits on the previous one's top, null counts as 0, zero baseline included).Screenshots or video
Same dashboard tile (raw SQL, stacked bar, 1200 + 800 per bucket, Number format, 0 decimals).
How to reproduce
Starting point:
yarn app:dev:localconnected to the demo server (onboarding → "Connect to Demo Server").On
main: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 ts0, 500, 1k, 2k, 2k.On this branch:
0, 500, 1k, 1.5k, 2k.How to test on Vercel preview
Preview routes: /dashboards
Steps:
0, 500, 1k, 1.5k, 2k, with no label repeated.References