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


##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx:
##########
@@ -63,6 +70,60 @@ const {
   yAxisIndex,
 } = DEFAULT_FORM_DATA;
 
+function hasBarSeriesInState(state: ControlPanelState | null): boolean {
+  const formData = state?.form_data;
+  const seriesA =
+    state?.controls?.seriesType?.value ?? formData?.seriesType ?? seriesType;
+  const seriesB =
+    state?.controls?.seriesTypeB?.value ?? formData?.seriesTypeB ?? seriesType;
+  return (
+    seriesA === EchartsTimeseriesSeriesType.Bar ||
+    seriesB === EchartsTimeseriesSeriesType.Bar
+  );
+}
+
+function isNumericXAxisState(state: ControlPanelState | null): boolean {
+  return checkColumnType(
+    getColumnLabel(state?.controls?.x_axis?.value as QueryFormColumn),
+    state?.controls?.datasource?.datasource,
+    [GenericDataType.Numeric],
+  );
+}
+
+const mixedXAxisForceCategoricalControl = {
+  ...xAxisForceCategoricalControl,
+  config: {
+    ...xAxisForceCategoricalControl.config,
+    description: t(
+      'Treat values as categorical. Enabled by default when any query uses bar 
series to prevent bar overflow and intermediate tick labels. Disable to use a 
continuous numeric x-axis that preserves spacing for missing values.',
+    ),
+    initialValue: (control: ControlState, state: ControlPanelState | null) => {
+      if (!isNumericXAxisState(state)) {
+        return control.value;
+      }
+      if (state?.form_data?.x_axis_sort !== undefined) {
+        return true;
+      }
+      if (control?.value !== undefined) {
+        return control.value;
+      }
+      return hasBarSeriesInState(state);

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag the non-numeric x-axis short-circuit in MixedTimeseries 
controlPanel; for Temporal x-axes, keep AxisType.Time unless 
xAxisForceCategorical is explicitly enabled, and only enforce categorical 
defaults for numeric axes/bar-series cases.
   
   **Applied to:**
     - `superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/**`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



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