codeant-ai-for-open-source[bot] commented on code in PR #36989:
URL: https://github.com/apache/superset/pull/36989#discussion_r2692704632


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -304,6 +313,21 @@ export default function transformProps(
     const entryName = String(entry.name || '');
     const seriesName = inverted[entryName] || entryName;
 
+    // Calculate min/max from data for horizontal bar charts
+    if (shouldCalculateDataBounds && entry.data && Array.isArray(entry.data)) {
+      (entry.data as [number, any][]).forEach((datum: [number, any]) => {
+        const value = datum[0];

Review Comment:
   **Suggestion:** Logic bug: the code reads the numeric value from `datum[0]`, 
but horizontal bar series datapoints use the second element for the numeric 
value; this causes non-numeric category values to be ignored and prevents 
`dataMin`/`dataMax` from being set correctly. Replace the index with the 
correct element (and adjust the cast) so numeric values are read from the 
actual numeric position. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Horizontal bar value labels hidden or clipped.
   - ⚠️ Timeseries ECharts axis bounds incorrect for bars.
   - ⚠️ Diverging (negative) bars mis-sized causing layout gaps.
   ```
   </details>
   
   ```suggestion
         (entry.data as [any, number][]).forEach((datum: [any, number]) => {
           const value = datum[1];
   ```
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Build a Timeseries ECharts horizontal bar chart (transformProps entry) in:
   
      - 
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
   
      - transformProps function begins in this file; see rawSeries.forEach at 
line 303.
   
   2. Ensure formData triggers the horizontal path:
   
      - orientation === OrientationType.Horizontal and
   
      - seriesType === EchartsTimeseriesSeriesType.Bar and
   
      - truncateYAxis === true (shouldCalculateDataBounds true at line 295).
   
   3. Provide normal bar data produced by extractSeries (typical shape 
[category, numeric])
   so
   
      rawSeries entries contain entry.data arrays of [string|number, number]; 
transformProps
      iterates
   
      over entry.data at the block starting at line 316.
   
   4. Observe current code reads datum[0] (line 318) — the category — so typeof 
check fails,
   
      dataMax/dataMin remain undefined, and later axis bounds assignment (lines 
~506-515)
   
      does not use data values, causing truncated/rounded axis and value labels 
cut off.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
   **Line:** 318:319
   **Comment:**
        *Logic Error: Logic bug: the code reads the numeric value from 
`datum[0]`, but horizontal bar series datapoints use the second element for the 
numeric value; this causes non-numeric category values to be ignored and 
prevents `dataMin`/`dataMax` from being set correctly. Replace the index with 
the correct element (and adjust the cast) so numeric values are read from the 
actual numeric position.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   ```
   </details>



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