bito-code-review[bot] commented on code in PR #44550:
URL: https://github.com/apache/superset/pull/44550#discussion_r4078297371
##########
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:
<!-- Bito Reply -->
The suggestion is appropriate and improves the code by centralizing the
verbose-label mapping logic, which ensures consistency and simplifies
maintenance if the fallback logic needs to be updated in the future.
**superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx**
```
const withVerboseLabel = (value: string) => ({
value,
label: dataset?.verbose_map?.[value] || value,
});
const fieldOptions = [
...columns.map(column => withVerboseLabel(getColumnLabel(column))),
...metricLabels.map(withVerboseLabel),
];
```
--
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]