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


##########
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.
   
   This is a really useful addition 👍 I'm sure this will be needed in the 
future at some point.



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