Repository navigation
fix(plugin-chart-echarts): limit the grain-based bar width cap to sub-daily grains - #45519
Anikesh0001 wants to merge 3 commits into
Conversation
…-daily grains getGrainBarMaxWidth capped bar width at one grain bucket for every grain in TIMEGRAIN_TO_TIMESTAMP. With the default Day grain on pre-aggregated monthly or yearly data, one day is a sliver of the axis, so bars were drawn under 1px wide. The cap was meant for sparse sub-daily data, as the comment in Timeseries/transformers.ts says. For a day or coarser grain, return undefined so bars keep the default cap and ECharts sizes them from the spacing of the data again. Fixes apache#45474 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45519 +/- ##
=======================================
Coverage 84.73% 84.73%
=======================================
Files 3069 3069
Lines 205767 205784 +17
Branches 48388 48404 +16
=======================================
+ Hits 174350 174374 +24
+ Misses 28123 28116 -7
Partials 3294 3294
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sfirke
left a comment
There was a problem hiding this comment.
Hello! Please see the new contributor guidelines here: https://github.com/apache/superset/wiki/New-Contributor-Welcome-&-Expectations In particular please include before + after screenshots of your manual local testing. This helps demonstrate that code authors have deployed their changes and tested them with manual QA and we avoid drive-by AI code contributions.
Before / after screenshots from local Storybook testingI independently rendered the PR's target case in Storybook from both revisions, using the same fixture, viewport, and chart dimensions. Setup
Before After The before revision draws the yearly and monthly bars as hairlines because the Day-grain cap is far narrower than the spacing between rows. The after revision keeps the default 100px cap for Day and coarser grains, so the bars render at a normal width. This was Storybook-level QA, not a full Superset web-server deployment. The fixture exercised The screenshot files are stored on a separate evidence branch of my public fork, not in the Superset repository. |
|
@sfirke are we ok to merge? This one is going into 7.0.0rc3, and the screens have been added to the PR |
|
I will try to deploy this today to kick the tires on my end. |
|
@sadpandajoe and @villebro, please see the two options I laid out in my comment in the issue: #45474 (comment) I am not sure that merging this PR is the right fix, it might be better to revert only the bar-width portion of #44628 |
sfirke
left a comment
There was a problem hiding this comment.
The left-most and right-most bars have their labels off center. This is from my test environment running this PR:
This is also evident in the screenshot you posted.
Separately, I want to get replies to my issue that this is linked to: are we better off reverting part of the PR that introduced this problem? This fix introduces its own downsides.


SUMMARY
Fixes #45474.
Since #44628,
getGrainBarMaxWidthcaps the bar width at one time-grain bucket for every grain inTIMEGRAIN_TO_TIMESTAMP. That cap was meant for sparse sub-daily data, as the comment inTimeseries/transformers.tssays ("For a sub-daily time grain, transformProps.ts overrides this…"). For Day and coarser grains it misbehaves when the data is spaced further apart than the grain, which is the common case of the default Day grain on pre-aggregated monthly or yearly rows. One day is then a sliver of the axis, and the bars are drawn as hairlines.This change follows the fix proposed in the issue:
getGrainBarMaxWidthreturnsundefinedwhen the grain is a day or longer (grainMs >= ONE_DAY_MS).Timeseries/transformProps.tsandMixedTimeseries/transformProps.ts) already keep the defaultbarMaxWidth: 100in that case, so ECharts sizes the bars from the spacing of the data again, as in 6.1.0.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
No screenshots from me. The issue has 6.1.0 vs 7.0.0rc2 screenshots of the same chart. The numbers come from the new tests, with an 800px chart and data from 2019-01-01 to 2024-01-01:
barMaxWidthbeforeTESTING INSTRUCTIONS
New tests:
plugins/plugin-chart-echarts/test/Timeseries/Bar/sparseSubDailyBarGeometry.test.ts: a Day grain on yearly and on monthly data, and a Month grain on yearly data, keep the default bar width cap.plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts: the same for a mixed chart with a bar series, with a Day grain on yearly data.All 4 fail on
master(they receive the hairline widths above) and pass with this change.Run locally with Node 24.16 / npm 11:
npx jest plugins/plugin-chart-echarts: 101 suites, 1391 tests passed. The existingPT1Htests for fix(echarts): fix sparse sub-daily bar sizing and x-axis mislabeling #44628 still pass.oxlintandoxfmt --checkon the changed files: clean.node scripts/check-type.js package=superset-frontend <changed files>(aftertsc --buildof the plugin project): no errors.To check it manually, follow the steps in #45474: a Bar Chart on a dataset with one row per year, x-axis on the temporal column, Time Grain left at Day. The bars should have normal width, as in 6.1.0.
ADDITIONAL INFORMATION
Generative AI disclosure, following the ASF guidelines: I used Claude Code (Claude Opus 5.5) to help investigate this issue and draft the change, the tests and this description. I reviewed the result, checked that the new tests fail on
master, and ran the checks above locally.🤖 Generated with Claude Code