This is an automated email from the ASF dual-hosted git repository.

msyavuz pushed a commit to branch msyavuz/fix/categorical-initialization
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 9c40ced3e3844625fdc43c7b3b95427d7df55823
Author: Mehmet Salih Yavuz <[email protected]>
AuthorDate: Wed Jan 14 09:28:40 2026 +0300

    fix(controls): Only initialize categorical control on numeric x axis
---
 .../src/shared-controls/customControls.tsx                  | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git 
a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx
 
b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx
index fc8f16ee88..f59a7e9898 100644
--- 
a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx
+++ 
b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx
@@ -218,8 +218,17 @@ export const xAxisForceCategoricalControl = {
     label: () => t('Force categorical'),
     default: false,
     description: t('Treat values as categorical.'),
-    initialValue: (control: ControlState, state: ControlPanelState | null) =>
-      state?.form_data?.x_axis_sort !== undefined || control.value,
+    initialValue: (control: ControlState, state: ControlPanelState | null) => {
+      const isNumericXAxis = checkColumnType(
+        getColumnLabel(state?.controls?.x_axis?.value as QueryFormColumn),
+        state?.controls?.datasource?.datasource,
+        [GenericDataType.Numeric],
+      );
+      if (!isNumericXAxis) {
+        return control.value;
+      }
+      return state?.form_data?.x_axis_sort !== undefined || control.value;
+    },
     renderTrigger: true,
     visibility: ({ controls }: { controls: ControlStateMapping }) =>
       checkColumnType(

Reply via email to