sfirke opened a new issue, #45489:
URL: https://github.com/apache/superset/issues/45489

   ### Bug description
   
   (I found this issue by hand, then wrote it up with Claude AI. I edited and 
am posting this by hand having read it all)
   
   This wasn't great in 6.1.0, here it has regressed a little as there is now a 
not-useful date on the start of the x-axis in addition to the end.
   
   In 7.0.0rc2, a Timeseries chart with a time grain forces a label at both 
ends of the x-axis. On a long date range this causes two problems.
   
   **1. The last label overlaps the tick label before it.** Our chart spans 
2014-03-05 to 2026-08-17 on a dashboard about 1,400px wide. The axis ends with 
`2026` and `Mon 17` drawn on top of each other, so it reads `2026Mon 17`.
   
   **2. The forced labels can be meaningless on their own.** With the default 
"Adaptive formatting" (`smart_date`) x-axis format, the first label is `Wed 05` 
and the last is `Mon 17`. Smart-date formatting picks the shortest format 
that's unambiguous next to its neighbors, but a forced boundary label has no 
neighbor that supplies a month or year. A reader sees `Wed 05  2016  2018 … 
2024  2026Mon 17` and can't tell which day `Wed 05` is.
   
   **Where the overlap comes from:** #43669 added `createSpacedXAxisFormatter` 
in `superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts`. It 
blanks a label that's too close to the previously shown label, and it exempts 
the forced boundary labels so they always show:
   
   ```ts
   const isBoundary =
     typeof value === 'number' && (value === domainMin || value === domainMax);
   if (
     !showAllLabels &&
     !isBoundary &&
     ...
     (value - lastShownValue) * pixelsPerMs < label.length * 
xAxisLabelCharWidthPx + xAxisLabelMinGapPx
   ) {
     return '';
   }
   ```
   
   The check only looks backward. When ECharts formats `2026`, the closest 
shown label is `2024`, so `2026` is kept. Then the forced `Mon 17` is exempt, 
so it's kept too. It's drawn with `alignMaxLabel: 'right'`, which pulls it left 
onto `2026`. Nothing compares a regular tick against the upcoming boundary 
label. hideOverlap is off whenever `showMaxLabel` is set (#42299), so ECharts 
doesn't fix it either.
   
   The first label has the same issue mirrored, but the first regular tick 
after it was usually far enough away in our case.
   
   **Where the labels come from:** #42046 added `showMinLabel` (the start label 
is new in 7.0). #42299 forces `showMaxLabel` so the last date isn't hidden; 
6.1.0 already showed a `Tue 15` style end label on this chart, but not a start 
label, and nothing overlapped.
   
   **How to reproduce**
   
   1. Create a Line Chart with time grain Day and data spanning about 12 years, 
ending in mid-August (e.g. 2014-03-05 to 2026-08-17).
   2. Leave X Axis Time Format on "Adaptive formatting" and Label rotation at 0.
   3. Put the chart on a dashboard at about 1,400px wide (or resize until the 
year tick just before the last date is drawn).
   4. The last two labels overlap (`2026Mon 17`), and the first label reads 
`Wed 05` with no month or year.
   
   **Expected behavior**
   
   - The forced boundary labels never overlap another label. When a regular 
tick would collide with a forced boundary label, the regular tick is the one 
dropped.
   - A forced boundary label carries enough context to stand alone, e.g. 
`2014-03-05` or `Mar 5, 2014`, instead of `Wed 05`.
   
   **Proposed fix**
   
   - In `createSpacedXAxisFormatter`, also blank a non-boundary label that 
would sit within the minimum gap of `domainMax` (and do the same for the label 
right after `domainMin`), accounting for the right/left alignment of the 
boundary labels.
   - When formatting a forced boundary label with smart_date, use a full date 
format (or at least day + month + year) rather than the smart, 
context-dependent one.
   
   ### Screenshots/recordings
   
   Here's the 7.0.0rc2 chart, look at the first and last date on the x-axis - 
they are not useful and in the right most case, cramped:
   
   <img width="1552" height="505" alt="Image" 
src="https://github.com/user-attachments/assets/1e7e708b-ea8c-4a6d-a671-5d0feacf68f5";
 />
   
   
   6.1.0 for comparison (due to stale cache the screenshot shows different end 
date) - it also has the bad end date:
   
   <img width="1540" height="477" alt="Image" 
src="https://github.com/user-attachments/assets/682d23b7-8fe5-4593-994e-ac62c323eb13";
 />
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   Not applicable
   
   ### Node version
   
   Not applicable
   
   ### Browser
   
   Not applicable
   
   ### Additional context
   
   - Superset 7.0.0rc2, Docker image built from the release. On 6.1.0 the same 
chart has no start label and no overlap.
   - Related PRs: #43669 (spacing formatter, boundary exemption), #42046 
(forced start label), #42299 (forced end label, fixing #39899).
   - The chart in the screenshot ends on Aug 17 because of a stale cache on our 
instance, not a Superset bug. With current data it ends on Sep 15, which 
doesn't change the label behavior described here.
   
   ### Checklist
   
   - [ ] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [ ] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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