mirror of
https://github.com/apache/superset.git
synced 2026-04-27 20:14:54 +00:00
refactor: create echarts query section (#20445)
This commit is contained in:
@@ -26,12 +26,12 @@ import {
|
||||
ChartProps,
|
||||
ChartDataResponseResult,
|
||||
QueryFormColumn,
|
||||
ContributionType,
|
||||
} from '@superset-ui/core';
|
||||
import {
|
||||
EchartsLegendFormData,
|
||||
EchartsTitleFormData,
|
||||
StackType,
|
||||
EchartsTimeseriesContributionType,
|
||||
EchartsTimeseriesSeriesType,
|
||||
} from '../types';
|
||||
import {
|
||||
@@ -63,8 +63,8 @@ export type EchartsMixedTimeseriesFormData = QueryFormData & {
|
||||
// types specific to Query A and Query B
|
||||
area: boolean;
|
||||
areaB: boolean;
|
||||
contributionMode?: EchartsTimeseriesContributionType;
|
||||
contributionModeB?: EchartsTimeseriesContributionType;
|
||||
contributionMode?: ContributionType;
|
||||
contributionModeB?: ContributionType;
|
||||
markerEnabled: boolean;
|
||||
markerEnabledB: boolean;
|
||||
markerSize: number;
|
||||
|
||||
@@ -22,27 +22,21 @@ import {
|
||||
ControlPanelConfig,
|
||||
ControlPanelsContainerProps,
|
||||
D3_TIME_FORMAT_DOCS,
|
||||
emitFilterControl,
|
||||
sections,
|
||||
sharedControls,
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
import {
|
||||
EchartsTimeseriesContributionType,
|
||||
EchartsTimeseriesSeriesType,
|
||||
} from '../types';
|
||||
import { EchartsTimeseriesSeriesType } from '../types';
|
||||
import { DEFAULT_FORM_DATA } from '../constants';
|
||||
import {
|
||||
legendSection,
|
||||
onlyTotalControl,
|
||||
showValueControl,
|
||||
richTooltipSection,
|
||||
xAxisControl,
|
||||
} from '../../controls';
|
||||
import { AreaChartExtraControlsOptions } from '../../constants';
|
||||
|
||||
const {
|
||||
contributionMode,
|
||||
logAxis,
|
||||
markerEnabled,
|
||||
markerSize,
|
||||
@@ -58,38 +52,7 @@ const {
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisControl],
|
||||
['metrics'],
|
||||
['groupby'],
|
||||
[
|
||||
{
|
||||
name: 'contributionMode',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Contribution Mode'),
|
||||
default: contributionMode,
|
||||
choices: [
|
||||
[null, 'None'],
|
||||
[EchartsTimeseriesContributionType.Row, 'Row'],
|
||||
[EchartsTimeseriesContributionType.Column, 'Series'],
|
||||
],
|
||||
description: t('Calculate contribution per series or row'),
|
||||
},
|
||||
},
|
||||
],
|
||||
['adhoc_filters'],
|
||||
emitFilterControl,
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
['row_limit'],
|
||||
['truncate_metric'],
|
||||
],
|
||||
},
|
||||
sections.echartsTimeSeriesQuery,
|
||||
sections.advancedAnalyticsControls,
|
||||
sections.annotationsAndLayersControls,
|
||||
sections.forecastIntervalControls,
|
||||
|
||||
@@ -24,26 +24,20 @@ import {
|
||||
ControlSetRow,
|
||||
ControlStateMapping,
|
||||
D3_TIME_FORMAT_DOCS,
|
||||
emitFilterControl,
|
||||
formatSelectOptions,
|
||||
sections,
|
||||
sharedControls,
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
import {
|
||||
EchartsTimeseriesContributionType,
|
||||
OrientationType,
|
||||
} from '../../types';
|
||||
import { OrientationType } from '../../types';
|
||||
import { DEFAULT_FORM_DATA } from '../../constants';
|
||||
import {
|
||||
legendSection,
|
||||
richTooltipSection,
|
||||
showValueSection,
|
||||
xAxisControl,
|
||||
} from '../../../controls';
|
||||
|
||||
const {
|
||||
contributionMode,
|
||||
logAxis,
|
||||
minorSplitLine,
|
||||
rowLimit,
|
||||
@@ -265,38 +259,7 @@ function createAxisControl(axis: 'x' | 'y'): ControlSetRow[] {
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisControl],
|
||||
['metrics'],
|
||||
['groupby'],
|
||||
[
|
||||
{
|
||||
name: 'contributionMode',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Contribution Mode'),
|
||||
default: contributionMode,
|
||||
choices: [
|
||||
[null, 'None'],
|
||||
[EchartsTimeseriesContributionType.Row, 'Row'],
|
||||
[EchartsTimeseriesContributionType.Column, 'Series'],
|
||||
],
|
||||
description: t('Calculate contribution per series or row'),
|
||||
},
|
||||
},
|
||||
],
|
||||
['adhoc_filters'],
|
||||
emitFilterControl,
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
['row_limit'],
|
||||
['truncate_metric'],
|
||||
],
|
||||
},
|
||||
sections.echartsTimeSeriesQuery,
|
||||
sections.advancedAnalyticsControls,
|
||||
sections.annotationsAndLayersControls,
|
||||
sections.forecastIntervalControls,
|
||||
|
||||
@@ -24,24 +24,18 @@ import {
|
||||
D3_TIME_FORMAT_DOCS,
|
||||
sections,
|
||||
sharedControls,
|
||||
emitFilterControl,
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
import {
|
||||
EchartsTimeseriesContributionType,
|
||||
EchartsTimeseriesSeriesType,
|
||||
} from '../../types';
|
||||
import { EchartsTimeseriesSeriesType } from '../../types';
|
||||
import { DEFAULT_FORM_DATA } from '../../constants';
|
||||
import {
|
||||
legendSection,
|
||||
richTooltipSection,
|
||||
showValueSection,
|
||||
xAxisControl,
|
||||
} from '../../../controls';
|
||||
|
||||
const {
|
||||
area,
|
||||
contributionMode,
|
||||
logAxis,
|
||||
markerEnabled,
|
||||
markerSize,
|
||||
@@ -57,38 +51,7 @@ const {
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisControl],
|
||||
['metrics'],
|
||||
['groupby'],
|
||||
[
|
||||
{
|
||||
name: 'contributionMode',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Contribution Mode'),
|
||||
default: contributionMode,
|
||||
choices: [
|
||||
[null, 'None'],
|
||||
[EchartsTimeseriesContributionType.Row, 'Row'],
|
||||
[EchartsTimeseriesContributionType.Column, 'Series'],
|
||||
],
|
||||
description: t('Calculate contribution per series or row'),
|
||||
},
|
||||
},
|
||||
],
|
||||
['adhoc_filters'],
|
||||
emitFilterControl,
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
['row_limit'],
|
||||
['truncate_metric'],
|
||||
],
|
||||
},
|
||||
sections.echartsTimeSeriesQuery,
|
||||
sections.advancedAnalyticsControls,
|
||||
sections.annotationsAndLayersControls,
|
||||
sections.forecastIntervalControls,
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
ControlPanelConfig,
|
||||
ControlPanelsContainerProps,
|
||||
D3_TIME_FORMAT_DOCS,
|
||||
emitFilterControl,
|
||||
sections,
|
||||
sharedControls,
|
||||
} from '@superset-ui/chart-controls';
|
||||
@@ -32,7 +31,6 @@ import {
|
||||
legendSection,
|
||||
richTooltipSection,
|
||||
showValueSection,
|
||||
xAxisControl,
|
||||
} from '../../../controls';
|
||||
|
||||
const {
|
||||
@@ -49,22 +47,7 @@ const {
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisControl],
|
||||
['metrics'],
|
||||
['groupby'],
|
||||
['adhoc_filters'],
|
||||
emitFilterControl,
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
['row_limit'],
|
||||
['truncate_metric'],
|
||||
],
|
||||
},
|
||||
sections.echartsTimeSeriesQuery,
|
||||
sections.advancedAnalyticsControls,
|
||||
sections.annotationsAndLayersControls,
|
||||
sections.forecastIntervalControls,
|
||||
|
||||
@@ -22,22 +22,18 @@ import {
|
||||
ControlPanelConfig,
|
||||
ControlPanelsContainerProps,
|
||||
D3_TIME_FORMAT_DOCS,
|
||||
emitFilterControl,
|
||||
sections,
|
||||
sharedControls,
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
import { EchartsTimeseriesContributionType } from '../../types';
|
||||
import { DEFAULT_FORM_DATA } from '../../constants';
|
||||
import {
|
||||
legendSection,
|
||||
richTooltipSection,
|
||||
showValueSectionWithoutStack,
|
||||
xAxisControl,
|
||||
} from '../../../controls';
|
||||
|
||||
const {
|
||||
contributionMode,
|
||||
logAxis,
|
||||
markerEnabled,
|
||||
markerSize,
|
||||
@@ -51,38 +47,7 @@ const {
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisControl],
|
||||
['metrics'],
|
||||
['groupby'],
|
||||
[
|
||||
{
|
||||
name: 'contributionMode',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Contribution Mode'),
|
||||
default: contributionMode,
|
||||
choices: [
|
||||
[null, 'None'],
|
||||
[EchartsTimeseriesContributionType.Row, 'Row'],
|
||||
[EchartsTimeseriesContributionType.Column, 'Series'],
|
||||
],
|
||||
description: t('Calculate contribution per series or row'),
|
||||
},
|
||||
},
|
||||
],
|
||||
['adhoc_filters'],
|
||||
emitFilterControl,
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
['row_limit'],
|
||||
['truncate_metric'],
|
||||
],
|
||||
},
|
||||
sections.echartsTimeSeriesQuery,
|
||||
sections.advancedAnalyticsControls,
|
||||
sections.annotationsAndLayersControls,
|
||||
sections.forecastIntervalControls,
|
||||
|
||||
@@ -24,24 +24,18 @@ import {
|
||||
D3_TIME_FORMAT_DOCS,
|
||||
sections,
|
||||
sharedControls,
|
||||
emitFilterControl,
|
||||
} from '@superset-ui/chart-controls';
|
||||
|
||||
import {
|
||||
EchartsTimeseriesContributionType,
|
||||
EchartsTimeseriesSeriesType,
|
||||
} from '../../types';
|
||||
import { EchartsTimeseriesSeriesType } from '../../types';
|
||||
import { DEFAULT_FORM_DATA } from '../constants';
|
||||
import {
|
||||
legendSection,
|
||||
richTooltipSection,
|
||||
showValueSection,
|
||||
xAxisControl,
|
||||
} from '../../controls';
|
||||
|
||||
const {
|
||||
area,
|
||||
contributionMode,
|
||||
logAxis,
|
||||
markerEnabled,
|
||||
markerSize,
|
||||
@@ -56,38 +50,7 @@ const {
|
||||
const config: ControlPanelConfig = {
|
||||
controlPanelSections: [
|
||||
sections.legacyTimeseriesTime,
|
||||
{
|
||||
label: t('Query'),
|
||||
expanded: true,
|
||||
controlSetRows: [
|
||||
[xAxisControl],
|
||||
['metrics'],
|
||||
['groupby'],
|
||||
[
|
||||
{
|
||||
name: 'contributionMode',
|
||||
config: {
|
||||
type: 'SelectControl',
|
||||
label: t('Contribution Mode'),
|
||||
default: contributionMode,
|
||||
choices: [
|
||||
[null, 'None'],
|
||||
[EchartsTimeseriesContributionType.Row, 'Row'],
|
||||
[EchartsTimeseriesContributionType.Column, 'Series'],
|
||||
],
|
||||
description: t('Calculate contribution per series or row'),
|
||||
},
|
||||
},
|
||||
],
|
||||
['adhoc_filters'],
|
||||
emitFilterControl,
|
||||
['limit'],
|
||||
['timeseries_limit_metric'],
|
||||
['order_desc'],
|
||||
['row_limit'],
|
||||
['truncate_metric'],
|
||||
],
|
||||
},
|
||||
sections.echartsTimeSeriesQuery,
|
||||
sections.advancedAnalyticsControls,
|
||||
sections.annotationsAndLayersControls,
|
||||
sections.forecastIntervalControls,
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
QueryFormColumn,
|
||||
QueryFormData,
|
||||
TimeGranularity,
|
||||
ContributionType,
|
||||
} from '@superset-ui/core';
|
||||
import {
|
||||
EchartsLegendFormData,
|
||||
@@ -31,11 +32,6 @@ import {
|
||||
StackType,
|
||||
} from '../types';
|
||||
|
||||
export enum EchartsTimeseriesContributionType {
|
||||
Row = 'row',
|
||||
Column = 'column',
|
||||
}
|
||||
|
||||
export enum OrientationType {
|
||||
vertical = 'vertical',
|
||||
horizontal = 'horizontal',
|
||||
@@ -55,7 +51,7 @@ export type EchartsTimeseriesFormData = QueryFormData & {
|
||||
annotationLayers: AnnotationLayer[];
|
||||
area: boolean;
|
||||
colorScheme?: string;
|
||||
contributionMode?: EchartsTimeseriesContributionType;
|
||||
contributionMode?: ContributionType;
|
||||
forecastEnabled: boolean;
|
||||
forecastPeriods: number;
|
||||
forecastInterval: number;
|
||||
|
||||
@@ -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 {
|
||||
ControlPanelsContainerProps,
|
||||
ControlSetItem,
|
||||
@@ -138,10 +138,6 @@ export const onlyTotalControl: ControlSetItem = {
|
||||
},
|
||||
};
|
||||
|
||||
export const xAxisControl = isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES)
|
||||
? 'x_axis'
|
||||
: null;
|
||||
|
||||
const percentageThresholdControl: ControlSetItem = {
|
||||
name: 'percentage_threshold',
|
||||
config: {
|
||||
|
||||
Reference in New Issue
Block a user