diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx index 355e61127e17..de11fadaec74 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx @@ -17,7 +17,12 @@ * under the License. */ import React, { useCallback } from 'react'; -import { DataRecordValue, QueryObjectFilterClause } from '@superset-ui/core'; +import { + AxisType, + DataRecordValue, + DTTM_ALIAS, + QueryObjectFilterClause, +} from '@superset-ui/core'; import { EchartsMixedTimeseriesChartTransformedProps } from './types'; import Echart from '../components/Echart'; import { EventHandlers } from '../types'; @@ -37,6 +42,7 @@ export default function EchartsMixedTimeseries({ seriesBreakdown, onContextMenu, xValueFormatter, + xAxis, }: EchartsMixedTimeseriesChartTransformedProps) { const isFirstQuery = useCallback( (seriesIndex: number) => seriesIndex < seriesBreakdown, @@ -116,18 +122,31 @@ export default function EchartsMixedTimeseries({ const { data, seriesIndex } = eventParams; if (data) { const pointerEvent = eventParams.event.event; - const values = labelMap[eventParams.seriesName]; - const { queryIndex } = (echartOptions.series as any)[seriesIndex]; - const groupby = queryIndex > 0 ? formData.groupbyB : formData.groupby; + const values = [ + ...(eventParams.name ? [eventParams.name] : []), + ...(isFirstQuery(seriesIndex) ? labelMap : labelMapB)[ + eventParams.seriesName + ], + ]; const filters: QueryObjectFilterClause[] = []; - filters.push({ - col: formData.granularitySqla, - grain: formData.timeGrainSqla, - op: '==', - val: data[0], - formattedVal: xValueFormatter(data[0]), - }); - groupby.forEach((dimension, i) => + if (xAxis.type === AxisType.time) { + filters.push({ + col: + xAxis.label === DTTM_ALIAS + ? formData.granularitySqla + : xAxis.label, + grain: formData.timeGrainSqla, + op: '==', + val: data[0], + formattedVal: xValueFormatter(data[0]), + }); + } + [ + ...(xAxis.type === AxisType.category ? [xAxis.label] : []), + ...(isFirstQuery(seriesIndex) + ? formData.groupby + : formData.groupbyB), + ].forEach((dimension, i) => filters.push({ col: dimension, op: '==', 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 e6e12b498d5f..14630a0f1368 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -499,5 +499,9 @@ export default function transformProps( selectedValues: filterState.selectedValues || [], onContextMenu, xValueFormatter: tooltipFormatter, + xAxis: { + label: xAxisCol, + type: xAxisType, + }, }; } diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts index 9a751d5d6bf9..a78429a786ab 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts @@ -25,6 +25,7 @@ import { QueryFormColumn, ContributionType, TimeFormatter, + AxisType, } from '@superset-ui/core'; import { EchartsLegendFormData, @@ -144,4 +145,8 @@ export type EchartsMixedTimeseriesChartTransformedProps = labelMapB: Record; seriesBreakdown: number; xValueFormatter: TimeFormatter | StringConstructor; + xAxis: { + label: string; + type: AxisType; + }; };