Skip to content

Commit

Permalink
fix: X Axis should be called Y Axis when using the Bar Chart V2 on Ho…
Browse files Browse the repository at this point in the history
…rizontal mode (#20659)
  • Loading branch information
diegomedina248 authored Jul 9, 2022
1 parent 542fdb2 commit c29261b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
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

0 comments on commit c29261b

Please sign in to comment.