Skip to content

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

Merged
kodiakhq[bot] merged 5 commits into
ClickHouse:mainfrom
jplorier:fix/x-axis-dates-multi-day-range
Dec 1, 2026
Merged

kodiakhq[bot] merged 5 commits into
ClickHouse:mainfrom
jplorier:fix/x-axis-dates-multi-day-range

Conversation

@jplorier

@jplorier jplorier commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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 x-axis label formatting with backward-compatible defaults when rangeSeconds is omitted; daily-or-coarser granularity and single-day sub-daily ranges are unchanged.

Overview
Fixes ambiguous x-axis labels on sub-daily time charts when the selected window spans more than one day: ticks after the first no longer show time-only strings that repeat across days.

getXAxisTickDateFormat gains optional rangeSeconds. Below daily granularity, behavior is unchanged for ranges ≤ 1 day (first tick normal, rest time). When rangeSeconds exceeds one day, every non-first tick uses the existing short format (date + compact time) instead of time only.

MemoChart derives rangeSeconds from dateRange and passes it into the x-axis tick formatter so chart explorer, dashboards, and compact tiles share the fix.

Unit and e2e chart-explorer tests cover multi-day vs within-day ranges; changeset is a patch on @hyperdx/app.

Reviewed by Cursor Bugbot for commit 3b40e14. 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: 50d794b

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

github-actions Bot commented Nov 30, 2026 •

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

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

Display-only change: getXAxisTickDateFormat gains an optional rangeSeconds param so that below daily granularity, ticks after the first show the date+time (short) when the range spans more than a day — otherwise bare time (time), unchanged. MemoChart derives rangeSeconds from its required dateRange tuple. The core logic is sound, type-safe, and well-covered by unit and e2e tests; the exactly-1-day boundary (> SECONDS_PER_DAY) and the omitted-rangeSeconds backward-compat path are both pinned by tests.

✅ No critical issues found.

🟡 P2 — recommended

  • packages/app/tests/e2e/features/chart-explorer.spec.ts:570 — the new multi-day e2e test matches each label against a format regex but never asserts the labels are distinct, so a regression that emits correctly-formatted yet repeated tick labels (the exact symptom being fixed) would still pass.
    • Fix: Add expect(new Set(labels).size).toBe(labels.length) to the multi-day test, mirroring the existing daily-granularity test's uniqueness assertion.
🔵 P3 nitpicks (2)
  • packages/app/src/HDXMultiSeriesTimeChart/axisTicks.ts:372 — the JSDoc says multi-day below-daily ticks all "carry the date and time," but index 0 returns normal (date + full time with seconds) while later ticks return short, so the first label renders differently from the rest.
    • Fix: Note in the doc that the first tick keeps the normal format and the remaining ticks use short.
  • packages/app/src/HDXMultiSeriesTimeChart/axisTicks.ts:391 — rangeSeconds?: number plus the rangeSeconds != null guard keeps a time-only fallback branch that only tests exercise; the sole production caller always supplies the value.
    • Fix: Add a one-line comment on why undefined preserves the prior single-day behavior, or make the param required if the fallback is not an intended contract.

Reviewers (8): correctness, testing, maintainability, project-standards, kieran-typescript, previous-comments, agent-native, learnings-researcher.

Testing gaps:

  • No unit test for rangeSeconds just above the boundary (e.g. SECONDS_PER_DAY + 1); only 7 days exercises the short path while exactly 1 day pins the time cutoff.

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

@vercel

vercel Bot commented Dec 1, 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 Dec 1, 2026 1:35pm UTC

Request Review

pulpdrew
pulpdrew previously approved these changes Dec 1, 2026

@pulpdrew pulpdrew 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.

LGTM, thanks for the contribution

@pulpdrew pulpdrew added automerge and removed needs-vouch Author needs a maintainer to vouch for them labels Dec 1, 2026
if (convertGranularityToSeconds(granularity) < SECONDS_PER_DAY) {
return index === 0 ? 'normal' : 'time';
if (index === 0) return 'normal';
return rangeSeconds != null && rangeSeconds > SECONDS_PER_DAY

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 — Multi-day sub-daily axis mixes normal and short label formats (first tick has seconds, others don't)

When rangeSeconds > SECONDS_PER_DAY, the first tick still returns 'normal' (Nov 23 12:00:00 AM) while every later tick returns 'short' (Nov 23 12:00PM). The axis then shows two different date/time styles, and the widest label sits at the preserved start position (MemoChart.tsx:970 interval="preserveStartEnd"). Every tick already carries the date in this mode, so the first one doesn't need the fuller format. Return 'short' for every index in the multi-day branch, as the daily-granularity branch below already does, and update the unit test (format(0, sevenDays)) and the e2e assertion on first to match.

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

@kodiakhq
kodiakhq Bot merged commit 92aa9c3 into ClickHouse:main Dec 1, 2026
27 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

2 participants