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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -314,12 +314,7 @@ export default function transformProps(
 
   const isMultiSeries = groupBy.length || metrics?.length > 1;
   const xAxisDataType = dataTypes?.[xAxisLabel] ?? dataTypes?.[xAxisOrig];
-  const xAxisType = getAxisType(
-    stack,
-    xAxisForceCategorical,
-    xAxisDataType,
-    seriesType,
-  );
+  const xAxisType = getAxisType(stack, xAxisForceCategorical, xAxisDataType);

Review Comment:
   **Suggestion:** This now relies entirely on `xAxisForceCategorical` to 
protect bar charts, but the render path still merges `DEFAULT_FORM_DATA` where 
`xAxisForceCategorical` is `false`. For legacy/external payloads that don’t 
explicitly send this control value, numeric bar charts will fall back to a 
value axis and reintroduce the overflow behavior this change is trying to keep 
fixed by default. Add a runtime fallback for bar series (or migrate defaults in 
transformed form data) so bar charts remain categorical unless users explicitly 
opt out. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Existing numeric bar timeseries charts lose overflow protection.
   - ❌ MixedTimeseries bars without flag use numeric x-axis.
   - ⚠️ Users see intermediate ticks and crowded bar rendering.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction βœ… </b></summary>
   
   ```mdx
   1. Load or render a regular bar timeseries chart (`viz_type` using
   `Timeseries/Regular/Bar`) with a numeric x-axis column (e.g. an integer 
`year` dimension)
   and unstacked series; the transform path is
   
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts`,
 which
   destructures form data at line ~276 as `}: EchartsTimeseriesFormData = {
   ...DEFAULT_FORM_DATA, ...formData };` (from the snippet starting at "Showing 
lines 250 to
   369").
   
   2. Ensure the chart’s `formData` (as sent from the backend or external 
client) does not
   include the `xAxisForceCategorical` field – this is the case for legacy 
charts created
   before the new control or any programmatic payload that never set the flag. 
Because of the
   destructuring in step 1, `xAxisForceCategorical` is then taken from
   `DEFAULT_FORM_DATA.xAxisForceCategorical`.
   
   3. Observe that `DEFAULT_FORM_DATA` for timeseries is defined in
   `superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts` 
at line ~81
   (`xAxisForceCategorical: false,` in the block shown for lines 60–119). With 
`formData`
   missing the field, the effective `xAxisForceCategorical` in `transformProps` 
is therefore
   `false` even for bar charts.
   
   4. When `transformProps` builds the ECharts options, it computes `xAxisType` 
at line 317
   (`const xAxisType = getAxisType(stack, xAxisForceCategorical, 
xAxisDataType);`), passing
   `stack` (false for unstacked bars), `xAxisForceCategorical` (false from 
defaults), and
   `xAxisDataType` (numeric via `getColtypesMapping`). The helper `getAxisType` 
in
   `superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts` at 
lines 14–28
   returns `AxisType.Value` when `forceCategorical` is false and `dataType` is
   `GenericDataType.Numeric` with no stack. This produces a numeric/value 
x-axis for the bar
   chart, reintroducing the overflow behavior that #39141 had previously 
mitigated for bars,
   despite the intention in `Timeseries/Regular/Bar/controlPanel.tsx` (lines 
69–37) to
   default the UI control to categorical. Since the runtime fallback is 
missing, any legacy
   or external bar chart payload without an explicit `xAxisForceCategorical` 
flag will hit
   this regression.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=220f85a96a6c496eb68748b3f4432369&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=220f85a96a6c496eb68748b3f4432369&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <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:** 317:317
   **Comment:**
        *Logic Error: This now relies entirely on `xAxisForceCategorical` to 
protect bar charts, but the render path still merges `DEFAULT_FORM_DATA` where 
`xAxisForceCategorical` is `false`. For legacy/external payloads that don’t 
explicitly send this control value, numeric bar charts will fall back to a 
value axis and reintroduce the overflow behavior this change is trying to keep 
fixed by default. Add a runtime fallback for bar series (or migrate defaults in 
transformed form data) so bar charts remain categorical unless users explicitly 
opt out.
   
   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.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41859&comment_hash=4c04ebc510ccbb4f7303644f1cfbb1b99a0d65a5cd388d112133581d0af2ce07&reaction=like'>πŸ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41859&comment_hash=4c04ebc510ccbb4f7303644f1cfbb1b99a0d65a5cd388d112133581d0af2ce07&reaction=dislike'>πŸ‘Ž</a>



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