chore: move xaxis to superset-ui (#20438)

This commit is contained in:
Yongjie Zhao
2022-06-20 22:36:27 +08:00
committed by GitHub
parent 60eb1094a4
commit 111affdb02
32 changed files with 192 additions and 174 deletions

View File

@@ -17,22 +17,15 @@
* under the License.
*/
import React from 'react';
import {
FeatureFlag,
isFeatureEnabled,
t,
validateNonEmpty,
} from '@superset-ui/core';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import {
ControlPanelsContainerProps,
ControlPanelState,
ControlSetItem,
ControlSetRow,
ControlState,
sharedControls,
} from '@superset-ui/chart-controls';
import { DEFAULT_LEGEND_FORM_DATA } from './types';
import { DEFAULT_FORM_DATA } from './Timeseries/types';
import { DEFAULT_LEGEND_FORM_DATA } from './constants';
import { DEFAULT_FORM_DATA } from './Timeseries/constants';
const { legendMargin, legendOrientation, legendType, showLegend } =
DEFAULT_LEGEND_FORM_DATA;
@@ -145,32 +138,9 @@ export const onlyTotalControl: ControlSetItem = {
},
};
export const xAxisControl: ControlSetItem = {
name: 'x_axis',
config: {
...sharedControls.groupby,
label: t('X-axis'),
default: (
control: ControlState,
controlPanel: Partial<ControlPanelState>,
) => {
// default to the chosen time column if x-axis is unset and the
// GENERIC_CHART_AXES feature flag is enabled
const { value } = control;
if (value) {
return value;
}
const timeColumn = controlPanel?.form_data?.granularity_sqla;
if (isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) && timeColumn) {
return timeColumn;
}
return null;
},
multi: false,
description: t('Dimension to use on x-axis.'),
validators: [validateNonEmpty],
},
};
export const xAxisControl = isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)
? 'x_axis'
: null;
const percentageThresholdControl: ControlSetItem = {
name: 'percentage_threshold',