zhaoyongjie commented on code in PR #21371:
URL: https://github.com/apache/superset/pull/21371#discussion_r966767976


##########
superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/constants.tsx:
##########
@@ -22,45 +22,17 @@ import {
   t,
   validateNonEmpty,
 } from '@superset-ui/core';
-import { ControlPanelState, ControlState } from '../types';
+import { ControlPanelState } from '../types';
 
-export const xAxisControlConfig = {
-  label: (state: ControlPanelState) => {
-    if (
-      isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) &&
-      state?.form_data?.orientation === 'horizontal'
-    ) {
-      return t('Y-axis');
-    }
+const getAxisLabel = (state: ControlPanelState): [string, string] =>
+  isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) &&
+  state?.form_data?.orientation === 'horizontal'
+    ? [t('Y-axis'), t('Dimension to use on y-axis.')]
+    : [t('X-axis'), t('Dimension to use on x-axis.')];
 
-    return t('X-axis');
-  },
-  default: (
-    control: ControlState,
-    controlPanel: Partial<ControlPanelState>,
-  ) => {
-    // default to the chosen time column if x-axis is unset and the
-    // GENERIC_CHART_AXES feature flag is enabled
-    const { value } = control;
-    if (value) {
-      return value;
-    }
-    const timeColumn = controlPanel?.form_data?.granularity_sqla;
-    if (isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && timeColumn) {
-      return timeColumn;
-    }
-    return null;
-  },

Review Comment:
   The X-Axis control `value` should be set instead of setting the `default` 
value because if the default value had been set, the X-Axis control wouldn't 
have chance to remove it(the X-AXIS always sets a default value). Let me find a 
way to set the X-Axis as the `sqla_grainularity` if `GENERIC_CHART_AXES` is 
enabled.



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