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 e6f7babf5d49e..e12cdfe6f8101 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts @@ -593,6 +593,7 @@ export default function transformProps( extractForecastValuesFromTooltipParams(forecastValue); const keys = Object.keys(forecastValues); + let focusedRow; keys.forEach(key => { const value = forecastValues[key]; // if there are no dimensions, key is a verbose name of a metric, @@ -627,12 +628,11 @@ export default function transformProps( : tooltipFormatterSecondary, }); rows.push(row); + if (key === focusedSeries) { + focusedRow = rows.length - 1; + } }); - return tooltipHtml( - rows, - tooltipFormatter(xValue), - keys.findIndex(key => key === focusedSeries), - ); + return tooltipHtml(rows, tooltipFormatter(xValue), focusedRow); }, }, legend: { 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 e53ac60f559a5..bed39c7bc5180 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts @@ -569,6 +569,7 @@ export default function transformProps( const showTotal = Boolean(isMultiSeries) && richTooltip && !isForecast; const showPercentage = showTotal && !forcePercentFormatter; const keys = Object.keys(forecastValues); + let focusedRow; keys.forEach(key => { const value = forecastValues[key]; if (value.observation === 0 && stack) { @@ -583,10 +584,15 @@ export default function transformProps( row.push(percentFormatter.format(value.observation / (total || 1))); } rows.push(row); + if (key === focusedSeries) { + focusedRow = rows.length - 1; + } }); if (stack) { - keys.reverse(); rows.reverse(); + if (focusedRow) { + focusedRow = rows.length - focusedRow - 1; + } } if (showTotal) { const totalRow = ['Total', formatter.format(total)]; @@ -595,11 +601,7 @@ export default function transformProps( } rows.push(totalRow); } - return tooltipHtml( - rows, - tooltipFormatter(xValue), - keys.findIndex(key => key === focusedSeries), - ); + return tooltipHtml(rows, tooltipFormatter(xValue), focusedRow); }, }, legend: {