geido commented on code in PR #37115:
URL: https://github.com/apache/superset/pull/37115#discussion_r2689791126
##########
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) => {
Review Comment:
There is a little bit of business logic hidden here, maybe one of those
cases where a comment could help
##########
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;
Review Comment:
```suggestion
return state?.form_data?.x_axis_sort ?? control.value;
```
--
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]