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


##########
superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx:
##########
@@ -146,35 +146,52 @@ export const xAxisSortControl = {
       const columns = [controls?.x_axis?.value as QueryFormColumn].filter(
         Boolean,
       );
-      const isSingleSortAvailable =
-        ensureIsArray(controls?.groupby?.value).length === 0;
-      const isMultiSortAvailable =
+      const isMultiSeries =
         !!ensureIsArray(controls?.groupby?.value).length ||
         ensureIsArray(controls?.metrics?.value).length > 1;
       const metrics = [
         ...ensureIsArray(controls?.metrics?.value as QueryFormMetric),
         controls?.timeseries_limit_metric?.value as QueryFormMetric,
       ].filter(Boolean);
       const metricLabels = [...new Set(metrics.map(getMetricLabel))];
+      // The x-axis column and every metric (the "Sort By" limit metric
+      // included) can order the axis with or without dimensions: the backend
+      // sort operator handles the single-series case, and the chart resolves
+      // a metric's pivoted columns through `label_map` when dimensions split
+      // it into several series.
+      const fieldOptions = [
+        ...columns.map(column => {
+          const value = getColumnLabel(column);
+          return { value, label: dataset?.verbose_map?.[value] || value };
+        }),
+        ...metricLabels.map(value => ({
+          value,
+          label: dataset?.verbose_map?.[value] || value,
+        })),
+      ];

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Duplicated verbose-label mapping</b></div>
   <div id="fix">
   
   The `dataset?.verbose_map?.[value] || value` fallback is written twice 
inside `fieldOptions` (column map and metric-label map). Extracting one 
`withVerboseLabel(value)` helper keeps both option lists consistent if the 
fallback logic ever changes.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
         const withVerboseLabel = (value: string) => ({
           value,
           label: dataset?.verbose_map?.[value] || value,
         });
         const fieldOptions = [
           ...columns.map(column => withVerboseLabel(getColumnLabel(column))),
           ...metricLabels.map(withVerboseLabel),
         ];
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #8e747c</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