bito-code-review[bot] commented on code in PR #41859:
URL: https://github.com/apache/superset/pull/41859#discussion_r4115057132


##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx:
##########
@@ -65,6 +76,60 @@ const {
   yAxisIndex,
 } = DEFAULT_FORM_DATA;
 
+function hasBarSeriesInState(state: ControlPanelState | null): boolean {
+  const formData = state?.form_data;
+  const seriesA =
+    state?.controls?.seriesType?.value ?? formData?.seriesType ?? seriesType;
+  const seriesB =
+    state?.controls?.seriesTypeB?.value ?? formData?.seriesTypeB ?? seriesType;
+  return (
+    seriesA === EchartsTimeseriesSeriesType.Bar ||
+    seriesB === EchartsTimeseriesSeriesType.Bar
+  );
+}
+
+function isNumericXAxisState(state: ControlPanelState | null): boolean {
+  return checkColumnType(
+    getColumnLabel(state?.controls?.x_axis?.value as QueryFormColumn),
+    state?.controls?.datasource?.datasource,
+    [GenericDataType.Numeric],
+  );
+}
+
+const mixedXAxisForceCategoricalControl = {
+  ...xAxisForceCategoricalControl,
+  config: {
+    ...xAxisForceCategoricalControl.config,
+    description: t(
+      'Treat values as categorical. Enabled by default when any query uses bar 
series to prevent bar overflow and intermediate tick labels. Disable to use a 
continuous numeric x-axis that preserves spacing for missing values.',
+    ),
+    initialValue: (control: ControlState, state: ControlPanelState | null) => {
+      if (!isNumericXAxisState(state)) {
+        return control.value;
+      }
+      if (state?.form_data?.x_axis_sort !== undefined) {
+        return true;
+      }
+      if (control?.value !== undefined) {
+        return control.value;
+      }
+      return hasBarSeriesInState(state);
+    },
+  },
+};
+
+const mixedSharedQuerySection: ControlPanelSectionConfig = {
+  label: t('Shared query fields'),
+  expanded: true,
+  controlSetRows: [
+    ['x_axis'],
+    ['time_grain_sqla'],
+    [mixedXAxisForceCategoricalControl],
+    [xAxisSortControl],
+    [xAxisSortAscControl],

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Dead sort controls</b></div>
   <div id="fix">
   
   The new `xAxisSortControl`/`xAxisSortAscControl` rows write 
`x_axis_sort`/`x_axis_sort_asc` into form_data, but nothing in MixedTimeseries 
consumes them: `transformProps` never passes `xAxisSortSeries` to 
`extractSeries` (lines 314/332), and `x_axis_sort` appears nowhere else in the 
MixedTimeseries dir (only line 110). Users can set a sort that has no effect on 
the chart.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #0f8cbf</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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