refactor: get Axis from a helper function (#21449)

This commit is contained in:
Yongjie Zhao
2022-09-16 15:57:45 +08:00
committed by GitHub
parent 33509ab7da
commit 2d16100dbc
10 changed files with 67 additions and 33 deletions

View File

@@ -20,9 +20,7 @@
import {
AnnotationLayer,
CategoricalColorNamespace,
DTTM_ALIAS,
GenericDataType,
getColumnLabel,
getNumberFormatter,
isEventAnnotationLayer,
isFormulaAnnotationLayer,
@@ -30,8 +28,9 @@ import {
isTimeseriesAnnotationLayer,
TimeseriesChartDataResponseResult,
t,
DTTM_ALIAS,
} from '@superset-ui/core';
import { isDerivedSeries } from '@superset-ui/chart-controls';
import { getAxis, isDerivedSeries } from '@superset-ui/chart-controls';
import { EChartsCoreOption, SeriesOption } from 'echarts';
import { ZRLineType } from 'echarts/types/src/util/types';
import {
@@ -149,8 +148,9 @@ export default function transformProps(
const colorScale = CategoricalColorNamespace.getScale(colorScheme as string);
const rebasedData = rebaseForecastDatum(data, verboseMap);
// todo: if the both granularity_sqla and x_axis are `null`, should throw an error
const xAxisCol =
verboseMap[xAxisOrig] || getColumnLabel(xAxisOrig || DTTM_ALIAS);
verboseMap[xAxisOrig] || getAxis(chartProps.rawFormData) || DTTM_ALIAS;
const isHorizontal = orientation === OrientationType.horizontal;
const { totalStackedValues, thresholdValues } = extractDataTotalValues(
rebasedData,