rusackas commented on code in PR #42610:
URL: https://github.com/apache/superset/pull/42610#discussion_r3685635786


##########
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),
+        ),
+      );
+      yAxisMax =
+        Number.isFinite(stackedTotalMax) && stackedTotalMax > 1

Review Comment:
   Good catch, @sadpandajoe. Limited the padding to row-contribution mode now, 
since sortedTotalValues holds the raw pre-normalization totals for Expand 
stacks. Expand still gets the flat 1 max, pushed with a test for both cases.



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