Skip to content

feat(echarts): respect time grain in time-series tooltips - #41350

Merged
rusackas merged 5 commits into
masterfrom
adopt/pr-31765-timeseries-grain
Jul 17, 2026
Merged

rusackas merged 5 commits into
masterfrom
adopt/pr-31765-timeseries-grain

Conversation

@rusackas

Copy link
Copy Markdown
Member

SUMMARY

Adopts #31765 (original by @gerbermichi), carrying forward the time-grain formatting fix while splitting it off from the i18n change and the breaking-change concerns raised on that PR by @villebro. @gerbermichi gave the go-ahead to pick this up on a fresh PR.

Time-series and mixed time-series tooltips now honor the chart's selected time grain — and any dashboard-level grain override delivered via extra_form_data — when no explicit tooltip time format is set. This matches the behavior the x-axis already applies through getSmartDateFormatter. Tooltips read grain-appropriate labels:

  • Day → 2021-01-07
  • Week → 2021-01-07 — 2021-01-13
  • Month → Jan 2021
  • Quarter → 2021 Q1
  • Year → 2021

An explicit custom tooltip time format always wins, so users who pinned a format see no change.

How this was ported

Most of the original PR's intent had already landed on master since it was opened:

The remaining genuine gap was the tooltip not receiving the time grain, so this PR focuses there. The original PR threaded the grain through getTimeFormatter using the SMART_DATE_VERBOSE_ID format id, but that path produced the literal string smart_date_verbose — getTimeFormatter treats the id as a d3 format string once a granularity is supplied. This reworks getTooltipTimeFormatter to use the granularity formatter (getTimeFormatter(undefined, grain)) instead, which renders the correct labels above. The dashboard-level override (extra_form_data.time_grain_sqla) is read with optional chaining to avoid the runtime-crash risk the review bots flagged on the original PR.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

See the before/after screenshots on the original PR #31765. Behavior here is the tooltip half of that change.

TESTING INSTRUCTIONS

  1. Create a Time-series or Mixed Time-series chart with a temporal x-axis.
  2. Set the Time Grain to Quarter (or Month/Year/Week) and leave the tooltip time format at its default.
  3. Hover the chart — the tooltip date should read 2021 Q1, Jan 2021, 2021, or a weekly range rather than a full timestamp.
  4. Set an explicit tooltip time format and confirm it is still respected verbatim.

Automated coverage: superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts adds unit tests asserting the rendered output of getTooltipTimeFormatter for each grain, the no-explicit-format case, and the explicit-format-wins case.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Adopts #31765, original by @gerbermichi. Includes an UPDATING.md note per @villebro's request on the original PR.

🤖 Generated with Claude Code

@dosubot dosubot Bot added change:frontend Requires changing the frontend explore:time Related to the time filters in Explore viz:charts:echarts Related to Echarts viz:charts:timeseries Related to Timeseries labels Jun 23, 2026
@bito-code-review

bito-code-review Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8ab929

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts - 1
Review Details
  • Files reviewed - 4 · Commit Range: 0ef74b6..0ef74b6
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas mentioned this pull request Jun 23, 2026
1 of 9 tasks
@codecov

codecov Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.62%. Comparing base (46a153d) to head (f4515d8).
⚠️ Report is 257 commits behind head on master.

Files with missing lines Patch % Lines
...hart-echarts/src/MixedTimeseries/transformProps.ts 90.00% 1 Missing ⚠️
...gin-chart-echarts/src/Timeseries/transformProps.ts 90.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #41350   +/-   ##
=======================================
  Coverage   64.61%   64.62%           
=======================================
  Files        2684     2684           
  Lines      148514   148524   +10     
  Branches    34263    34272    +9     
=======================================
+ Hits        95969    95981   +12     
+ Misses      50786    50784    -2     
  Partials     1759     1759           
Flag Coverage Δ
javascript 69.41% <92.59%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eschutho
eschutho requested a review from kgabryje June 23, 2026 21:07
@rusackas
rusackas force-pushed the adopt/pr-31765-timeseries-grain branch from 0ef74b6 to 4223c94 Compare June 25, 2026 01:39
@bito-code-review

bito-code-review Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3977af

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 4223c94..bc298b4
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas force-pushed the adopt/pr-31765-timeseries-grain branch from bc298b4 to d53b7bf Compare June 25, 2026 18:36
@bito-code-review

bito-code-review Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #79a181

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 1d6ad5d..48e91a7
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas force-pushed the adopt/pr-31765-timeseries-grain branch from 48e91a7 to 453095b Compare June 26, 2026 21:43
@bito-code-review

bito-code-review Bot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1454b5

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts - 2
    • Defensive null handling gap · Line 934-938
      The `minInterval` branch uses `TIMEGRAIN_TO_TIMESTAMP[resolvedTimeGrain] ?? 0`, which silently returns 0 for any invalid key. If `resolvedTimeGrain` holds a value not in `TIMEGRAIN_TO_TIMESTAMP`, this would be a silent logical error — the x-axis would render with no minimum interval rather than failing explicitly. Consider adding a guard or logging to catch unexpected grain values.
    • Missing test for grain override · Line 735-735
      The `resolvedTimeGrain` feature (line 730-731) is tested only indirectly through existing time grain tests. No test explicitly verifies that `extraFormData.time_grain_sqla` takes precedence over `timeGrainSqla` for tooltip/x-axis formatting. Consider adding test coverage for this specific code path.
  • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts - 1
    • Missing test coverage for new feature · Line 583-601
      The diff adds `extraFormData?.time_grain_sqla` override support but existing tests don't verify this behavior. Add test cases covering: (1) default behavior when extraFormData is undefined, (2) override when extraFormData.time_grain_sqla differs from timeGrainSqla, (3) interaction with showMaxLabel deduplication logic.
Review Details
  • Files reviewed - 4 · Commit Range: 5159ddf..453095b
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

rusackas and others added 3 commits July 2, 2026 20:43
Adopts #31765 (original by @gerbermichi), splitting the time-grain
formatting fix out from the i18n change and breaking-change concerns
raised on that PR.

Time-series and mixed time-series tooltips now honor the chart's time
grain (and any dashboard-level override delivered via extra_form_data)
when no explicit tooltip time format is set, matching the behavior the
x-axis already applies via getSmartDateFormatter. Tooltips read
grain-appropriate labels such as 'Jan 2021' (month), '2021 Q1'
(quarter), '2021' (year), and weekly date ranges. An explicit custom
tooltip format always wins.

The original PR threaded the grain through getTimeFormatter using the
SMART_DATE_VERBOSE_ID format id, which produced the literal string
'smart_date_verbose' because getTimeFormatter treats the id as a d3
format string when a granularity is supplied. This reworks the tooltip
path to use the granularity formatter (getTimeFormatter(undefined,
grain)) instead, with unit-test coverage proving the rendered output for
each grain. Adds an UPDATING.md note per villebro's request.

Co-Authored-By: Michael Gerber <michael.gerber@nxt.engineering>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Align minInterval/maxInterval guards with the resolved grain so
dashboard-level time_grain_sqla overrides drive tick spacing the same
way they already drive tooltip and x-axis label formatting, and fall
back safely when a grain is missing from TIMEGRAIN_TO_TIMESTAMP.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The showMaxLabel/dedup branch still keyed off chart-level timeGrainSqla
while formatter and interval logic use resolvedTimeGrain. Align it so a
dashboard grain override drives axis-label overlap handling too.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rusackas
rusackas force-pushed the adopt/pr-31765-timeseries-grain branch from 453095b to fd176a1 Compare July 3, 2026 03:44
@bito-code-review

bito-code-review Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #36849c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: e864594..fd176a1
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@kgabryje

kgabryje commented Jul 13, 2026 •

Copy link
Copy Markdown
Member

Two things worth addressing before merge:

  1. Missing test coverage on the actual wiring. The new tests in formatters.test.ts only exercise getTooltipTimeFormatter directly with manually-passed args — nothing exercises resolvedTimeGrain/the extra_form_data override through the full transformProps pipeline for either Timeseries or MixedTimeseries (and MixedTimeseries has no tooltip/grain coverage at all despite duplicating the same logic). Worth adding one pipeline-level test per plugin asserting the override reaches the rendered tooltip.

  2. UPDATING.md wording is a bit overstated.

    • "matching the behavior already applied to the x-axis" — tooltip and x-axis both become grain-aware but don't render identical labels/ranges (e.g. tooltip shows 2021 Q1 / weekly ranges vs. more compact x-axis labels). Maybe soften to "grain-aware."
    • "Charts that pin an explicit tooltip time format are unaffected" — SMART_DATE_ID ("Adaptive formatting") is both the default and an explicitly selectable option, and it's routed through the new grain-aware branch either way. Only a genuinely custom d3 format string is guaranteed unaffected.

…UPDATING.md wording

Adds transformProps-level tests for Timeseries and MixedTimeseries asserting
that an extra_form_data time-grain override reaches the rendered tooltip, and
softens the UPDATING.md note per review feedback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rusackas

Copy link
Copy Markdown
Member Author

Thanks @kgabryje, both fixed. Added transformProps-level tests for Timeseries and MixedTimeseries confirming the extra_form_data grain override reaches the rendered tooltip, and softened the UPDATING.md wording, Adaptive formatting is grain-aware too, only a custom d3 format string is unaffected.

@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 8ecbd63
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a54bc31c2fca80007a95f5c
😎 Deploy Preview https://deploy-preview-41350--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4fb616

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts - 1
    • Semantic duplication across files · Line 1803-1867
      The exact same 'Tooltip time grain wiring' describe block (same test names, same grain resolutions, same assertions) appears in MixedTimeseries/transformProps.test.ts. This creates maintenance burden — any logic change requires updating 4 tests in 2 places.
Review Details
  • Files reviewed - 2 · Commit Range: fd176a1..8ecbd63
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

…asts

Addresses bot review feedback: use standalone test() cases instead of a
new describe() wrapper, and type the tooltip formatter access instead of
casting to any.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3b83c9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 8ecbd63..f4515d8
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas merged commit 9ccd365 into master Jul 17, 2026
66 checks passed
@rusackas
rusackas deleted the adopt/pr-31765-timeseries-grain branch July 17, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend explore:time Related to the time filters in Explore plugins size/L viz:charts:echarts Related to Echarts viz:charts:timeseries Related to Timeseries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants