rusackas opened a new pull request, #41350:
URL: https://github.com/apache/superset/pull/41350

   ### 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 x-axis grain-aware formatting was implemented by #38017 
(`getSmartDateFormatter(timeGrain)`).
   - The tooltip verbose formatter was touched by #33138.
   
   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:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to