msyavuz commented on code in PR #37115:
URL: https://github.com/apache/superset/pull/37115#discussion_r2691690938
##########
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:
The original returns true if x_axis_sort is defined (regardless of its
value) OR if control.value is truthy
The suggestion returns the value of x_axis_sort if it exists (including
falsy values), otherwise returns 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]