diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts index 62ed57268f699..fe70bdff5e67c 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -48,7 +48,10 @@ import { getColtypesMapping, getLegendProps, } from '../utils/series'; -import { extractAnnotationLabels } from '../utils/annotation'; +import { + extractAnnotationLabels, + getAnnotationData, +} from '../utils/annotation'; import { extractForecastSeriesContext, extractForecastValuesFromTooltipParams, @@ -81,11 +84,11 @@ export default function transformProps( filterState, datasource, theme, - annotationData = {}, } = chartProps; const { verboseMap = {} } = datasource; const data1 = (queriesData[0].data || []) as TimeseriesDataRecord[]; const data2 = (queriesData[1].data || []) as TimeseriesDataRecord[]; + const annotationData = getAnnotationData(chartProps); const { area, diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts index 2f19ad512ae88..ba651a60da394 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -17,7 +17,6 @@ * under the License. */ /* eslint-disable camelcase */ -import { isEmpty } from 'lodash'; import { AnnotationLayer, CategoricalColorNamespace, @@ -32,7 +31,6 @@ import { isTimeseriesAnnotationLayer, TimeseriesChartDataResponseResult, t, - AnnotationData, } from '@superset-ui/core'; import { isDerivedSeries } from '@superset-ui/chart-controls'; import { EChartsCoreOption, SeriesOption } from 'echarts'; @@ -57,7 +55,10 @@ import { extractDataTotalValues, extractShowValueIndexes, } from '../utils/series'; -import { extractAnnotationLabels } from '../utils/annotation'; +import { + extractAnnotationLabels, + getAnnotationData, +} from '../utils/annotation'; import { extractForecastSeriesContext, extractForecastSeriesContexts, @@ -83,16 +84,6 @@ import { TIMEGRAIN_TO_TIMESTAMP, } from '../constants'; -function getAnnotationData( - chartProps: EchartsTimeseriesChartProps, -): AnnotationData { - const data = chartProps?.queriesData[0]?.annotation_data as AnnotationData; - if (!isEmpty(data)) { - return data; - } - return {}; -} - export default function transformProps( chartProps: EchartsTimeseriesChartProps, ): TimeseriesChartTransformedProps { diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts b/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts index f59dbf99fbeae..3a95082863126 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/utils/annotation.ts @@ -17,6 +17,8 @@ * specific language governing permissions and limitations * under the License. */ +import { isEmpty } from 'lodash'; + import { Annotation, AnnotationData, @@ -30,6 +32,8 @@ import { isTimeseriesAnnotationResult, TimeseriesDataRecord, } from '@superset-ui/core'; +import { EchartsTimeseriesChartProps } from '../types'; +import { EchartsMixedTimeseriesProps } from '../MixedTimeseries/types'; export function evalFormula( formula: FormulaAnnotationLayer, @@ -130,3 +134,13 @@ export function extractAnnotationLabels( return formulaAnnotationLabels.concat(timeseriesAnnotationLabels); } + +export function getAnnotationData( + chartProps: EchartsTimeseriesChartProps | EchartsMixedTimeseriesProps, +): AnnotationData { + const data = chartProps?.queriesData[0]?.annotation_data as AnnotationData; + if (!isEmpty(data)) { + return data; + } + return {}; +}