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

chore: move xaxis to superset-ui #20438

Merged
merged 5 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -67,6 +67,8 @@ import {
ExtraControlProps,
SelectControlConfig,
Dataset,
ControlState,
ControlPanelState,
} from '../types';
import { ColumnOption } from '../components/ColumnOption';

Expand Down Expand Up @@ -544,6 +546,30 @@ const enableExploreDnd = isFeatureEnabled(
FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP,
);

const x_axis: SharedControlConfig = {
...(enableExploreDnd ? dndGroupByControl : groupByControl),
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],
};

const sharedControls = {
metrics: enableExploreDnd ? dnd_adhoc_metrics : metrics,
metric: enableExploreDnd ? dnd_adhoc_metric : metric,
Expand Down Expand Up @@ -579,6 +605,7 @@ const sharedControls = {
series_limit_metric: enableExploreDnd ? dnd_sort_by : sort_by,
legacy_order_by: enableExploreDnd ? dnd_sort_by : sort_by,
truncate_metric,
x_axis,
};

export { sharedControls, dndEntity, dndColumnsControl };
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {

import { DEFAULT_FORM_DATA } from './types';
import { EchartsTimeseriesSeriesType } from '../Timeseries/types';
import { legendSection, richTooltipSection, xAxisControl } from '../controls';
import { legendSection, richTooltipSection } from '../controls';

const {
area,
Expand Down Expand Up @@ -295,7 +295,7 @@ const config: ControlPanelConfig = {
? {
label: t('Shared query fields'),
expanded: true,
controlSetRows: [[xAxisControl]],
controlSetRows: [['x_axis']],
}
: null,
createQuerySection(t('Query A'), ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
Expand All @@ -31,7 +31,7 @@ import {
DEFAULT_FORM_DATA,
EchartsTimeseriesContributionType,
EchartsTimeseriesSeriesType,
} from '../types';
} from '@superset-ui/plugin-chart-echarts';
import {
legendSection,
onlyTotalControl,
Expand Down Expand Up @@ -62,7 +62,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? [xAxisControl] : [],
[xAxisControl],
['metrics'],
['groupby'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
Expand All @@ -34,7 +34,7 @@ import {
DEFAULT_FORM_DATA,
EchartsTimeseriesContributionType,
OrientationType,
} from '../../types';
} from '@superset-ui/plugin-chart-echarts';
import {
legendSection,
richTooltipSection,
Expand Down Expand Up @@ -269,7 +269,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? [xAxisControl] : [],
[xAxisControl],
['metrics'],
['groupby'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import {
isFeatureEnabled,
t,
} from '@superset-ui/core';
import buildQuery from '../../buildQuery';
import controlPanel from './controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import {
EchartsTimeseriesChartProps,
EchartsTimeseriesFormData,
EchartsTimeseriesSeriesType,
} from '../../types';
} from '@superset-ui/plugin-chart-echarts';
import buildQuery from '../../buildQuery';
import controlPanel from './controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import example1 from './images/Bar1.png';
import example2 from './images/Bar2.png';
import example3 from './images/Bar3.png';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
Expand All @@ -31,13 +31,13 @@ import {
DEFAULT_FORM_DATA,
EchartsTimeseriesContributionType,
EchartsTimeseriesSeriesType,
} from './types';
} from '@superset-ui/plugin-chart-echarts';
import {
legendSection,
richTooltipSection,
showValueSection,
xAxisControl,
} from '../controls';
} from '../../../controls';

const {
area,
Expand All @@ -61,7 +61,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? [xAxisControl] : [],
[xAxisControl],
['metrics'],
['groupby'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import {
isFeatureEnabled,
t,
} from '@superset-ui/core';
import buildQuery from '../../buildQuery';
import controlPanel from '../controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import {
EchartsTimeseriesChartProps,
EchartsTimeseriesFormData,
EchartsTimeseriesSeriesType,
} from '../../types';
} from '@superset-ui/plugin-chart-echarts';
import buildQuery from '../../buildQuery';
import controlPanel from './controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import example1 from './images/Line1.png';
import example2 from './images/Line2.png';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
Expand All @@ -27,7 +27,7 @@ import {
sharedControls,
} from '@superset-ui/chart-controls';

import { DEFAULT_FORM_DATA } from '../../types';
import { DEFAULT_FORM_DATA } from '@superset-ui/plugin-chart-echarts';
import {
legendSection,
richTooltipSection,
Expand All @@ -53,7 +53,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? [xAxisControl] : [],
[xAxisControl],
['metrics'],
['groupby'],
['adhoc_filters'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import {
isFeatureEnabled,
t,
} from '@superset-ui/core';
import buildQuery from '../../buildQuery';
import controlPanel from './controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import {
EchartsTimeseriesChartProps,
EchartsTimeseriesFormData,
EchartsTimeseriesSeriesType,
} from '../../types';
} from '@superset-ui/plugin-chart-echarts';
import buildQuery from '../../buildQuery';
import controlPanel from './controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import example1 from './images/Scatter1.png';

const scatterTransformProps = (chartProps: EchartsTimeseriesChartProps) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
Expand All @@ -27,13 +27,16 @@ import {
sharedControls,
} from '@superset-ui/chart-controls';

import { DEFAULT_FORM_DATA, EchartsTimeseriesContributionType } from '../types';
import {
DEFAULT_FORM_DATA,
EchartsTimeseriesContributionType,
} from '@superset-ui/plugin-chart-echarts';
import {
legendSection,
richTooltipSection,
showValueSectionWithoutStack,
xAxisControl,
} from '../../controls';
} from '../../../controls';

const {
contributionMode,
Expand All @@ -54,7 +57,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? [xAxisControl] : [],
[xAxisControl],
['metrics'],
['groupby'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import {
isFeatureEnabled,
t,
} from '@superset-ui/core';
import buildQuery from '../../buildQuery';
import controlPanel from '../controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import {
EchartsTimeseriesChartProps,
EchartsTimeseriesFormData,
EchartsTimeseriesSeriesType,
} from '../../types';
} from '@superset-ui/plugin-chart-echarts';
import buildQuery from '../../buildQuery';
import controlPanel from './controlPanel';
import transformProps from '../../transformProps';
import thumbnail from './images/thumbnail.png';
import example1 from './images/SmoothLine1.png';

const smoothTransformProps = (chartProps: EchartsTimeseriesChartProps) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlPanelsContainerProps,
Expand All @@ -31,7 +31,7 @@ import {
DEFAULT_FORM_DATA,
EchartsTimeseriesContributionType,
EchartsTimeseriesSeriesType,
} from '../types';
} from '@superset-ui/plugin-chart-echarts';
import {
legendSection,
richTooltipSection,
Expand Down Expand Up @@ -60,7 +60,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) ? [xAxisControl] : [],
[xAxisControl],
['metrics'],
['groupby'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import {
isFeatureEnabled,
t,
} from '@superset-ui/core';
import {
EchartsTimeseriesChartProps,
EchartsTimeseriesFormData,
} from '@superset-ui/plugin-chart-echarts';
import buildQuery from '../buildQuery';
import controlPanel from './controlPanel';
import transformProps from '../transformProps';
import thumbnail from './images/thumbnail.png';
import {
EchartsTimeseriesChartProps,
EchartsTimeseriesFormData,
} from '../types';
import example1 from './images/Step1.png';
import example2 from './images/Step2.png';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
t,
} from '@superset-ui/core';
import buildQuery from './buildQuery';
import controlPanel from './controlPanel';
import controlPanel from './Regular/Line/controlPanel';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import {
Expand Down
Loading