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>
[](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)
[](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]