Skip to content

fix(app): show dates on x-axis ticks at daily granularity - #3779

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
warren/gh-issue-9220
Nov 24, 2026
Merged

kodiakhq[bot] merged 1 commit into
mainfrom
warren/gh-issue-9220

Conversation

@wrn14897

@wrn14897 wrn14897 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Time charts formatted the first x-axis tick as date and time and every other tick as time only, whatever the granularity. At 1 day granularity every tick after the first read 12:00:00 AM (or 00:00:00 on a 24h clock), so a daily chart looked like it was broken down by hour. The data and the hover tooltip were correct; only the axis labels were wrong.

At daily granularity or coarser, ticks now show the date (Oct 27). Day buckets are UTC-aligned, so outside UTC they don't start at local midnight. In that case the tick shows the date and time (Oct 26 7:00PM), so the label stays accurate about where the bucket starts. Sub-day granularity is unchanged.

  • packages/common-utils: new date format (MMM d) for formatDate.
  • packages/app: getXAxisTickDateFormat picks the tick format from the granularity, tick time and display time zone; xTickFormatter in MemoChart uses it. This covers every time chart (chart explorer, dashboard tiles, compact tiles).
  • Unit tests for the helper and the new format.
  • E2E tests in chart-explorer.spec.ts with the browser time zone pinned: UTC at 1 day (every tick is a date), UTC at 1 hour (unchanged behavior), and America/New_York at 1 day (date and time). With the fix reverted, both daily tests fail with the original labels; the 1 hour test passes on both.

Out of scope: sub-day granularity over a multi-day range (e.g. 7 days at 12 hours) also shows time-only ticks without dates. Changing that affects most multi-day charts, so it should be a separate change.

Screenshots or video

Chart explorer, E2E Logs, count of events, last 30 days, 1 Day Granularity, 12h clock. I couldn't upload images from the CLI; I'll add the screenshots below. Tick labels as rendered:

Before After
UTC Oct 25 12:00:00 AM, 12:00:00 AM, 12:00:00 AM, … Oct 25, Oct 29, Nov 2, … Nov 24
America/New_York Oct 24 8:00:00 PM, 8:00:00 PM, 7:00:00 PM, … Oct 24 8:00PM, Oct 29 8:00PM, Nov 3 7:00PM, …
Before After
before-utc after-utc
before-new-york after-new-york

How to reproduce

Starting point: play.hyperdx.io/chart, or yarn app:dev:local → onboarding → "Connect to Demo Server". Set your display time zone to UTC (time picker → time zone) to match the first row above.

On main:

  1. Open Chart explorer and click "Connect to Demo Server" if prompted.
  2. Set the time range to the last 30 days.
  3. Set the granularity to "1 Day Granularity" and click "Run".
  4. Only the first x-axis tick shows a date; the rest show 12:00:00 AM.

On this branch:

  1. Repeat the same steps.
  2. Every x-axis tick shows a date (Oct 25, Oct 29, …).
  3. Switch the display time zone to America/New_York and run again: ticks show the date and time (Oct 24 8:00PM, …).
  4. Switch to "1 Hour Granularity" over the last 2 days: labels are unchanged from main (date on the first tick, time only on the rest).

How to test on Vercel preview

Preview routes: /chart

Steps:

  1. Open /chart and click "Connect to Demo Server" if prompted.
  2. Open the time picker, choose the last 30 days, and apply.
  3. Select "1 Day Granularity" in the granularity picker.
  4. Click "Run".
  5. Verify every x-axis tick label on the chart is a date such as "Oct 27" or a date with a time such as "Oct 26 7:00PM", and none is a time alone such as "12:00:00 AM".

References

Time charts formatted the first x-axis tick as date and time and every
other tick as time only, whatever the granularity. At 1 day granularity
every tick after the first read 00:00:00, so daily charts looked hourly.

At daily granularity or coarser, ticks now show the date ("Oct 27"). Day
buckets are UTC-aligned, so when a bucket does not start at midnight in
the display time zone the tick shows the date and time ("Oct 26 7:00PM").
Sub-day granularity is unchanged.

Refs HDX-6176
@wrn14897
wrn14897 requested a review from a team as a code owner November 24, 2026 03:50
@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eba74fa

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

This PR includes changesets to release 4 packages
Name Type
@hyperdx/app Patch
@hyperdx/common-utils 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

@vercel

vercel Bot commented Nov 24, 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 24, 2026 3:54am UTC
hyperdx-storybook Ready Ready Preview Nov 24, 2026 3:54am UTC

Request Review

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 24, 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

Additional context: spans packages but only 67 prod lines — under the 100-line cross-layer bar

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: 3
  • Production lines changed: 67 (+ 199 in test files, excluded from tier calculation)
  • Branch: warren/gh-issue-9220
  • Author: wrn14897

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 107 in total (1.12%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

1 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 1 P3

No inline comments. 1 P3 folded at the bottom.

🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/useFormatTime.tsx:9 — The DateFormat union is now written out by hand in two places that have to be kept in sync → Derive the type from the format keys instead of writing it out twice. Export type DateFormat = keyof typeof TIME_TOKENS from packages/common-utils/src/core/utils.ts, use it in formatDate's format option (utils.ts:865), and alias it here with export type DateFormat = _DateFormat;. This PR had to add 'date' to both the union here and the inline union in formatDate, and it now exports the app copy for HDXMultiSeriesTimeChart. The repo's REQUIRED 'Before you add a type' rule says to alias the canonical definition rather than retype it.

Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The change is well-scoped and correct. Reviewers confirmed the two paths stay consistent: getXAxisTickDateFormat decides the format using displayTimeZone and MemoChart renders with the same useDisplayTimeZone() value, so the midnight decision and the rendered label never disagree (including the undefined → getLocalTimeZone() / fnsFormat local-zone fallback). Unrecognized granularity (convertGranularityToSeconds returns 0) safely falls through to the prior normal/time behavior, and passing granularity: string into convertGranularityToSeconds(SQLInterval) is type-safe (SQLInterval erases to string). No P1/P2 issues surfaced.

🔵 P3 nitpicks (3)
  • packages/app/src/__tests__/HDXMultiSeriesTimeChart.test.ts:1371 — Every getXAxisTickDateFormat test passes an explicit timeZone, so the new timeZone ?? getLocalTimeZone() fallback branch is never exercised.
    • Fix: Add a daily-granularity case with timeZone: undefined (under a pinned TZ or with getLocalTimeZone stubbed) asserting the format resolves via the browser zone.
  • packages/common-utils/src/__tests__/utils.test.ts:107 — The new date token adds both 12h and 24h entries but only the 12h path is asserted, so a regression in the 24h token would go uncaught.
    • Fix: Add an assertion with clock: '24h', format: 'date' locking the same Jan 2 output.
  • packages/common-utils/src/core/utils.ts:865 — The format union is hand-maintained in three spots (TIME_TOKENS keys, formatDate's inline union, and the exported DateFormat in useFormatTime.tsx); adding date required editing all three.
    • Fix: Derive the type from the token table, e.g. export type DateFormat = keyof typeof TIME_TOKENS, and have formatDate/useFormatTime consume it.
    • maintainability, kieran-typescript

Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, previous-comments.

Testing gaps:

  • formatDate({ format: 'date' }) local-zone branch (no timeZone) is untested, mirroring the pre-existing pattern for other tokens.
  • The non-midnight short branch is only asserted for whole-hour-offset zones; half-hour/45-min-offset zones (e.g. Asia/Kolkata) are covered by the logic but not directly asserted.

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

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 475 passed • 1 skipped • 1103s

Status Count
✅ Passed 475
❌ Failed 0
⚠️ Flaky 13
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@kodiakhq
kodiakhq Bot merged commit b362d33 into main Nov 24, 2026
35 checks passed
@kodiakhq
kodiakhq Bot deleted the warren/gh-issue-9220 branch November 24, 2026 08:37

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — eba74fad Deployed Nov 24, 2026 by vercel[bot]
Preview – hyperdx-storybook — eba74fad Deployed Nov 24, 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.

2 participants