Copilot commented on code in PR #42300:
URL: https://github.com/apache/superset/pull/42300#discussion_r3679057256


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -724,6 +724,41 @@ export default function transformProps(
     }
   }
 
+  // Whenever a Y axis bound is defined, whether explicitly configured or
+  // derived above from the data, clamp series values to those bounds
+  // instead of leaving raw out-of-range values in place. ECharts axis
+  // clipping can otherwise drop an out-of-bounds point (and the line
+  // segments around it) entirely rather than truncating it at the
+  // boundary (see https://github.com/apache/superset/issues/27449).
+  if (yAxisMin !== undefined || yAxisMax !== undefined) {
+    const valueIndex = isHorizontal ? 0 : 1;
+    const clampAxisValue = (
+      value: string | number | null | undefined,
+    ): string | number | null | undefined => {
+      if (typeof value !== 'number' || Number.isNaN(value)) return value;
+      let clamped = value;
+      if (yAxisMin !== undefined) clamped = Math.max(clamped, yAxisMin);
+      if (yAxisMax !== undefined) clamped = Math.min(clamped, yAxisMax);
+      return clamped;
+    };
+    series.forEach(s => {
+      if (!Array.isArray(s.data)) return;
+      const clampedData = (
+        s.data as (string | number | null | undefined)[][]
+      ).map(point => {
+        if (Array.isArray(point)) {
+          const newPoint = [...point];
+          newPoint[valueIndex] = clampAxisValue(newPoint[valueIndex]);
+          return newPoint;
+        }
+        return point;
+      });
+      // Matches the existing pattern used elsewhere in this file for
+      // narrowing the broad, union-typed ECharts `SeriesOption.data` field.
+      (s as any).data = clampedData;
+    });

Review Comment:
   The clamping logic only adjusts tuple points (e.g. `[x, y]`). Some series 
paths (e.g. `colorByPrimaryAxis`) use object data items like `{ value: [x, y], 
itemStyle: ... }`, which this code will skip, so out-of-range values can still 
be dropped by ECharts in those modes. It also relies on `(s as any).data` to 
assign back. Consider clamping both tuple points and `{ value: [...] }` points 
and assign back with a typed cast instead of `any`.



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