Skip to content

Commit

Permalink
move AxisType in to core
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed Oct 18, 2022
1 parent f1b7803 commit 80a5a1b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ export const chartLabelWeight: Record<ChartLabel, { weight: number }> = {
},
};

export enum AxisType {
category = 'category',
value = 'value',
time = 'time',
log = 'log',
}

export default {};
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
* under the License.
*/
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { DTTM_ALIAS, QueryObjectFilterClause } from '@superset-ui/core';
import {
DTTM_ALIAS,
QueryObjectFilterClause,
AxisType,
} from '@superset-ui/core';
import { ViewRootGroup } from 'echarts/types/src/util/types';
import GlobalModel from 'echarts/types/src/model/Global';
import ComponentModel from 'echarts/types/src/model/Component';
import { AxisType, EchartsHandler, EventHandlers } from '../types';
import { EchartsHandler, EventHandlers } from '../types';
import Echart from '../components/Echart';
import { TimeseriesChartTransformedProps } from './types';
import { currentSeries } from '../utils/series';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
TimeseriesChartDataResponseResult,
t,
getXAxis,
AxisType,
} from '@superset-ui/core';
import { isDerivedSeries } from '@superset-ui/chart-controls';
import { EChartsCoreOption, SeriesOption } from 'echarts';
Expand All @@ -39,7 +40,6 @@ import {
EchartsTimeseriesSeriesType,
TimeseriesChartTransformedProps,
OrientationType,
AxisType,
} from './types';
import { DEFAULT_FORM_DATA } from './constants';
import { ForecastSeriesEnum, ForecastValue } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
TimeFormatter,
TimeseriesAnnotationLayer,
TimeseriesDataRecord,
AxisType,
} from '@superset-ui/core';
import { SeriesOption } from 'echarts';
import {
Expand All @@ -52,12 +53,7 @@ import {
import { MarkLine1DDataItemOption } from 'echarts/types/src/component/marker/MarkLineModel';

import { extractForecastSeriesContext } from '../utils/forecast';
import {
AxisType,
ForecastSeriesEnum,
LegendOrientation,
StackType,
} from '../types';
import { ForecastSeriesEnum, LegendOrientation, StackType } from '../types';
import { EchartsTimeseriesSeriesType } from './types';

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
TimeGranularity,
ContributionType,
TimeFormatter,
AxisType,
} from '@superset-ui/core';
import {
EchartsLegendFormData,
Expand Down Expand Up @@ -101,10 +102,3 @@ export type TimeseriesChartTransformedProps =
type: AxisType;
};
};

export enum AxisType {
category = 'category',
value = 'value',
time = 'time',
log = 'log',
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import {
isRecordAnnotationResult,
isTableAnnotationLayer,
isTimeseriesAnnotationResult,
AxisType,
} from '@superset-ui/core';
import { AxisType, EchartsTimeseriesChartProps } from '../types';
import { EchartsTimeseriesChartProps } from '../types';
import { EchartsMixedTimeseriesProps } from '../MixedTimeseries/types';

export function evalFormula(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ import {
NumberFormats,
NumberFormatter,
TimeFormatter,
AxisType,
} from '@superset-ui/core';
import { format, LegendComponentOption, SeriesOption } from 'echarts';
import {
AreaChartExtraControlsValue,
NULL_STRING,
TIMESERIES_CONSTANTS,
} from '../constants';
import { AxisType, LegendOrientation, LegendType, StackType } from '../types';
import { LegendOrientation, LegendType, StackType } from '../types';
import { defaultLegendPadding } from '../defaults';

function isDefined<T>(value: T | undefined | null): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
* under the License.
*/
import {
AnnotationLayer,
AnnotationData,
AnnotationLayer,
AnnotationOpacity,
AnnotationSourceType,
AnnotationStyle,
AnnotationType,
AxisType,
DataRecord,
FormulaAnnotationLayer,
TimeseriesDataRecord,
DataRecord,
} from '@superset-ui/core';
import {
evalFormula,
Expand Down Expand Up @@ -161,7 +162,7 @@ describe('evalFormula', () => {
{ __timestamp: 10 },
];

expect(evalFormula(layer, data, '__timestamp', 'time')).toEqual([
expect(evalFormula(layer, data, '__timestamp', AxisType.time)).toEqual([
[0, 1],
[10, 11],
]);
Expand All @@ -178,7 +179,7 @@ describe('evalFormula', () => {
{ ...layer, value: 'y = x* 2 -1' },
data,
'__timestamp',
'time',
AxisType.time,
),
).toEqual([
[0, -1],
Expand All @@ -190,7 +191,12 @@ describe('evalFormula', () => {
const data: DataRecord[] = [{ gender: 'boy' }, { gender: 'girl' }];

expect(
evalFormula({ ...layer, value: 'y = 1000' }, data, 'gender', 'category'),
evalFormula(
{ ...layer, value: 'y = 1000' },
data,
'gender',
AxisType.category,
),
).toEqual([
['boy', 1000],
['girl', 1000],
Expand Down

0 comments on commit 80a5a1b

Please sign in to comment.