rusackas commented on code in PR #42610:
URL: https://github.com/apache/superset/pull/42610#discussion_r3685634573
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -688,7 +688,25 @@ 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) {
+ // 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.
+ const stackedTotalMax = Math.max(
+ ...sortedTotalValues.filter(
+ (v): v is number => typeof v === 'number' && !Number.isNaN(v),
+ ),
+ );
Review Comment:
Good catch, swapped the spread for a reduce so a big series cant blow the
argument limit.
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -688,7 +688,25 @@ 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) {
+ // 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.
+ const stackedTotalMax = Math.max(
+ ...sortedTotalValues.filter(
+ (v): v is number => typeof v === 'number' && !Number.isNaN(v),
+ ),
+ );
Review Comment:
Good catch, swapped the spread for a reduce so a big series can't blow the
argument limit.
--
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]