fix(explore): pin and fix clipped segments in horizontal row-contribution stacked bar charts - #42610
fix(explore): pin and fix clipped segments in horizontal row-contribution stacked bar charts#42610rusackas wants to merge 4 commits into
Conversation
Code Review Agent Run #a1b6e5Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
The flagged issue is correct. Using the spread operator ( Here is the corrected implementation for the logic in const stackedTotalMax = sortedTotalValues.reduce((max, v) => {
if (typeof v === 'number' && !Number.isNaN(v)) {
return Math.max(max, v);
}
return max;
}, -Infinity);I have checked the available PR comments, and there are no other review comments to address. Would you like me to proceed with any other tasks? superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42610 +/- ##
=======================================
Coverage 65.59% 65.60%
=======================================
Files 2819 2819
Lines 160166 160199 +33
Branches 36569 36586 +17
=======================================
+ Hits 105065 105093 +28
- Misses 53053 53058 +5
Partials 2048 2048
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:
|
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #784aa2Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Code Review Agent Run #c5df3fActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…tion stacked bar charts Contribution percentages are normalized so a stacked row should sum to 1, but floating point rounding can push the actual stacked total fractionally above 1 (e.g. 1.0000000000000002). Hard-capping the row-contribution axis max at exactly 1 in that case caused echarts to clip the topmost stacked segment entirely on the axis swapped for horizontal orientation, instead of just rounding the pixel width. Pad the axis max up to the actual stacked total when it exceeds 1 so no segment gets clipped. Fixes #30914 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
`sortedTotalValues` holds pre-normalization row totals. For
contributionMode=row those are already ~1 (the case this PR targets),
but for an Expand ("100% stacked") chart they're the raw, un-normalized
sums, so padding the axis max against them stretched the chart out to
the raw total instead of the intended 0-1 range. Limit the padding to
row-contribution mode and keep the flat 1 max for Expand stacks.
Also swap the Math.max(...spread) for a reduce so a very large series
count can't blow the JS argument-spread limit.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
sortedTotalValues summed every series value per row regardless of stack, so with time_compare each independently-normalized comparison period inflated the combined row total, pushing the axis max to ~N instead of ~1 and shrinking 100% bars accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Series are sorted by name (descending) for stacking, so summing three shares whose overflow is a single float ULP can round differently depending on that order, making the test flaky. Widen the margin above 1 so the assertion holds regardless of summation order. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0e2185b to
7f22d73
Compare
Code Review Agent Run #55b55cActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
In a horizontal, stacked, row-contribution (100%) bar chart, some segments could vanish from the render entirely even though the underlying percentages were correct and summed to 100%.
The row-contribution axis max was hard-coded to exactly
1. Contribution shares are normalized so a stacked row is supposed to sum to1, but floating point rounding can push the actual stacked total fractionally above1(e.g.1.0000000000000002). When that happens, capping the axis max at exactly1causes echarts to clip the topmost stacked segment entirely on the swapped axis used for horizontal bars, instead of just rounding the pixel width. This lines up with the community's own workaround of nudging "Truncate Y Axis" max to1.00001, which happened to sidestep the same edge case.This PR pads the axis max up to the actual stacked total when it exceeds
1, so no segment gets clipped, while leaving the0-1default in place for the (much more common) case where the total is exactly1or below.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — this is a floating point edge case in axis-bounds calculation; see the reproduction and screenshots already on the issue.
TESTING INSTRUCTIONS
pytest-equivalent for the frontend:npm run test -- plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts— new testshould not clip small segments when row-contribution percentages float above 1 in horizontal stacked bar chartspins the regression.ADDITIONAL INFORMATION