Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: X Axis should be called Y Axis when using the Bar Chart V2 on Horizontal mode #20659

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ import {
import { ControlPanelState, ControlState } from '../types';

export const xAxisControlConfig = {
label: t('X-axis'),
label: (state: ControlPanelState) => {
if (
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) &&
state?.form_data?.orientation === 'horizontal'
) {
return t('Y-axis');
}

return t('X-axis');
},
default: (
control: ControlState,
controlPanel: Partial<ControlPanelState>,
Expand All @@ -43,6 +52,15 @@ export const xAxisControlConfig = {
return null;
},
multi: false,
description: t('Dimension to use on x-axis.'),
description: (state: ControlPanelState) => {
if (
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) &&
state?.form_data?.orientation === 'horizontal'
) {
return t('Dimension to use on y-axis.');
}

return t('Dimension to use on x-axis.');
},
validators: [validateNonEmpty],
};
18 changes: 16 additions & 2 deletions superset-frontend/packages/superset-ui-chart-controls/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,22 @@ export interface BaseControlConfig<
V = JsonValue,
> extends AnyDict {
type: T;
label?: ReactNode;
description?: ReactNode;
label?:
| ReactNode
| ((
state: ControlPanelState,
controlState: ControlState,
// TODO: add strict `chartState` typing (see superset-frontend/src/explore/types)
chartState?: AnyDict,
) => ReactNode);
description?:
| ReactNode
| ((
state: ControlPanelState,
controlState: ControlState,
// TODO: add strict `chartState` typing (see superset-frontend/src/explore/types)
chartState?: AnyDict,
) => ReactNode);
default?: V;
renderTrigger?: boolean;
validators?: ControlValueValidator<T, O, V>[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,35 @@ export const ControlPanelsContainer = (props: ControlPanelsContainerProps) => {
undefined),
name,
};
const { validationErrors, ...restProps } = controlData as ControlState & {
const {
validationErrors,
label: baseLabel,
description: baseDescription,
...restProps
} = controlData as ControlState & {
validationErrors?: any[];
};

const isVisible = visibility
? visibility.call(config, props, controlData)
: undefined;

const label =
typeof baseLabel === 'function'
? baseLabel(exploreState, controls[name], chart)
: baseLabel;

const description =
typeof baseDescription === 'function'
? baseDescription(exploreState, controls[name], chart)
: baseDescription;

return (
<Control
key={`control-${name}`}
name={name}
label={label}
description={description}
validationErrors={validationErrors}
actions={props.actions}
isVisible={isVisible}
Expand Down
2 changes: 2 additions & 0 deletions superset/translations/nl/LC_MESSAGES/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,8 @@
],
"X-axis": [""],
"Dimension to use on x-axis.": [""],
"Y-axis": [""],
"Dimension to use on y-axis.": [""],
"Percentage threshold": [""],
"Minimum threshold in percentage points for showing labels.": [""],
"Rich tooltip": [""],
Expand Down