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


##########
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:
   Hi @villebro, I have added a new property for controls, `initialValue`. It 
refers to how to initialize a control when loading, this setting avoids the 
default value always set to the control.
   
   I also tested charts between FF enabled and disabled.
   1. Create a Bar Chart V2 when `GENERIC_CHART_AXES` is disabled, and then 
create a dashboard and take the chart.
   2. Open the `GENERIC_CHART_AXES`
   3. the Chart on the Explore page and Dashboard same as the disabled FF.



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