rusackas commented on code in PR #42610:
URL: https://github.com/apache/superset/pull/42610#discussion_r3709809085
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -688,7 +688,35 @@ export default function transformProps(
// default to 0-100% range when doing row-level contribution chart
if ((contributionMode === 'row' || isAreaExpand) && stack) {
if (yAxisMin === undefined) yAxisMin = 0;
- if (yAxisMax === undefined) yAxisMax = 1;
+ if (yAxisMax === undefined) {
+ if (contributionMode === 'row') {
+ // Contribution percentages are normalized so each 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 axis max at exactly 1 in that case causes echarts to clip the
+ // topmost stacked segment entirely rather than just rounding the
+ // pixel width, which is most visible in horizontal orientation where
+ // this axis is swapped onto the x-axis. Pad the max up to the actual
+ // stacked total when it exceeds 1 so no segment gets clipped.
+ //
+ // This padding only applies in row-contribution mode: for an Expand
+ // ("100% stacked") chart, `sortedTotalValues` holds the raw,
+ // pre-normalization row totals (e.g. 100), not values near 1, so
+ // padding against them here would stretch the axis out to the raw
+ // total instead of the intended 0-1 range.
+ const stackedTotalMax = sortedTotalValues.reduce<number>(
+ (max, v) =>
+ typeof v === 'number' && !Number.isNaN(v) ? Math.max(max, v) : max,
+ Number.NEGATIVE_INFINITY,
+ );
+ yAxisMax =
Review Comment:
Good catch — the padding was computed from `sortedTotalValues`, which sums
every column per row regardless of stack. Fixed to compute the max per ECharts
stack instead, with a test covering row-contribution + time_compare.
--
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]