Skip to content

fix(app): show dates on x-axis ticks over multi-day ranges below daily granularity - #3868

Open
jplorier wants to merge 1 commit into
ClickHouse:mainfrom
jplorier:fix/x-axis-dates-multi-day-range
Open

jplorier wants to merge 1 commit into
ClickHouse:mainfrom
jplorier:fix/x-axis-dates-multi-day-range

Conversation

@jplorier

@jplorier jplorier commented Nov 30, 2026 •

Copy link
Copy Markdown

Summary

Fixes #3867.

Below daily granularity, only the first x-axis tick of a time chart carried the date. On a range longer than a day (e.g. last 7 days at 12 hour granularity), every later tick repeated a bare time of day, so you had to hover to tell which day a point belongs to. #3779 fixed the daily-granularity case and called this one out as a separate follow-up.

  • getXAxisTickDateFormat takes an optional rangeSeconds. Below daily granularity, when the range spans more than a day, every tick after the first uses the existing short format (date and time, e.g. Nov 24 12:00PM). The first tick keeps normal. Ranges within a day, and every granularity of a day or coarser, are unchanged.
  • MemoChart passes the chart's dateRange span, so this covers every time chart (chart explorer, dashboard tiles, compact tiles).
  • Unit tests for the multi-day case and for ranges within a day.
  • Changeset: @hyperdx/app patch.

Screenshots or video

I couldn't capture screenshots from my setup. Tick labels as formatted, 12h clock, UTC, last 7 days at 12 hour granularity:

Before After
Nov 23 12:00:00 AM, 12:00:00 PM, 12:00:00 AM, 12:00:00 PM, … Nov 23 12:00:00 AM, Nov 23 12:00PM, Nov 24 12:00AM, Nov 24 12:00PM, …

How to reproduce

  1. Open the chart explorer on play.hyperdx.io, or yarn app:dev:local connected to the demo server.
  2. Count of events, range "Last 7 days", granularity "12 hour".
  3. On main, every tick after the first shows only a time. On this branch, every tick shows the date and time.
  4. Set the range to "Last 6 hours" at "1 hour". Ticks after the first stay time-only on both.

Tests

  • npx jest src/HDXMultiSeriesTimeChart/__tests__/HDXMultiSeriesTimeChart.test.ts: 125 passed.
  • yarn tsc --noEmit and yarn lint (oxlint + oxfmt) in packages/app: pass.

Note

Low Risk
UI-only label formatting in the time chart component with optional parameter preserving prior behavior when range is omitted or ≀ one day.

Overview
Fixes ambiguous x-axis labels on time charts when the selected range spans more than one day at sub-daily granularity (e.g. last 7 days at 12-hour buckets). Previously, only the first tick showed the date; later ticks showed bare times that repeated across days.

getXAxisTickDateFormat now accepts optional rangeSeconds. For granularities finer than one day, if the range exceeds a day, every tick after the first uses the short format (date + time) instead of time only. The first tick still uses normal; single-day ranges and daily-or-coarser granularities are unchanged.

MemoChart computes the span from dateRange and passes it into the x-axis tick formatter so chart explorer, dashboards, and compact tiles all pick up the behavior. Unit tests cover multi-day and within-a-day cases; changeset is a patch on @hyperdx/app.

Reviewed by Cursor Bugbot for commit f6ca101. Bugbot is set up for automated code reviews on this repo. Configure here.

…y granularity

Below daily granularity only the first x-axis tick carried the date, so on a
range longer than a day (e.g. last 7 days at 12 hour granularity) every later
tick repeated a bare time of day. getXAxisTickDateFormat now takes the chart's
range and, when it spans more than a day, formats every tick after the first
with the date and time ('short'). Ranges within a day are unchanged.

Follow-up to ClickHouse#3779, which fixed daily granularity and left this case out of
scope.

Fixes ClickHouse#3867
@jplorier
jplorier requested a review from a team as a code owner November 30, 2026 18:48
@vercel

vercel Bot commented Nov 30, 2026

Copy link
Copy Markdown

@jplorier is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added external needs-vouch Author needs a maintainer to vouch for them labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi @jplorier, thanks for the pull request!

Before we review code from a first-time contributor, a maintainer vouches for them, and you're not on our list yet. There's nothing else to file and this PR stays open β€” a maintainer will look at it, usually within a day or two, and vouch for you right here if it's a genuine attempt at the problem.

To make that quick, check the PR description has:

  • The issue it addresses (ideally one labelled Accepting PR) and why the change is needed
  • Steps to reproduce the problem and verify the fix, starting from https://play.hyperdx.io or yarn app:dev:local connected to the demo server
  • Before/after screenshots if anything in the UI changed

More detail in our contributing guide.

@changeset-bot

changeset-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

πŸ¦‹ Changeset detected

Latest commit: f6ca101

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

}): DateFormat {
if (convertGranularityToSeconds(granularity) < SECONDS_PER_DAY) {
return index === 0 ? 'normal' : 'time';
if (index === 0) return 'normal';

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.

🟑 P2 β€” On a multi-day range the first tick uses a different date-time format from every other tick

In the multi-day branch, return 'short' for index 0 as well, so the whole axis uses one date-time format. The daily-or-coarser branch below already does this. As written, the first tick still returns 'normal' (with seconds and a space before AM/PM), so the axis reads Nov 23 12:00:00 AM, Nov 23 12:00PM, Nov 24 12:00AM, … (the PR description's own 'After' row shows this). Update the test at HDXMultiSeriesTimeChart.test.ts:1398 to expect 'short' for index 0.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@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 Β· 🟑 1 P2 Β· πŸ”΅ 0 P3

1 posted as inline comment(s) on the changed lines.


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.

This is a small, well-scoped fix. Below daily granularity, getXAxisTickDateFormat now gains an optional rangeSeconds and returns short (date + time) instead of time (time only) for ticks after the first when the range spans more than a day; the first tick stays normal, and within-a-day ranges and daily-or-coarser granularity are unchanged. Reviewers independently confirmed the edge behavior is safe: an invalid dateRange yields NaN, which fails NaN > SECONDS_PER_DAY and degrades to time without crashing; deriving rangeSeconds as a primitive and adding it to the xTickFormatter useCallback deps only recreates the callback when the numeric span actually changes, sidestepping the known fresh-dateRange-reference churn; and the exact-24h boundary correctly stays time. The new multi-day and within-a-day branches are both unit-tested, the omitted-rangeSeconds backward-compat path is covered incidentally by a pre-existing test, and the changeset scope (@hyperdx/app patch) is correct.

πŸ”΅ P3 nitpicks (1)
  • packages/app/src/HDXMultiSeriesTimeChart/axisTicks.ts:394 β€” over a multi-day sub-daily range the first tick renders normal (MMM d h:mm:ss a, with seconds) while every later tick renders short (MMM d h:mma, no seconds), so the first tick alone shows seconds; before this change both normal and time carried seconds, so precision was uniform.
    • Fix: use a seconds-free date+time format for the first tick in this branch, or drop seconds across the branch, so every tick in the multi-day range shows the same precision.

Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races.

Testing gaps: none substantive β€” the new short, within-day time, and day-boundary branches are all covered; the uncovered MemoChart rangeSeconds arithmetic and an exact-86400s boundary assertion are trivial and optional.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external needs-vouch Author needs a maintainer to vouch for them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Time chart x-axis drops the date after the first tick on multi-day ranges below daily granularity

1 participant