fix(plugin-chart-echarts): sort tooltip correctly (#30819)

This commit is contained in:
Ville Brofeldt
2024-11-01 15:24:51 -07:00
committed by GitHub
parent d466383df2
commit b02d18a39e
4 changed files with 122 additions and 63 deletions

View File

@@ -642,3 +642,22 @@ export function getTimeCompareStackId(
}) || defaultId
);
}
const TOOLTIP_SERIES_KEY = 'seriesId';
export function extractTooltipKeys(
forecastValue: any[],
yIndex: number,
richTooltip?: boolean,
tooltipSortByMetric?: boolean,
): string[] {
if (richTooltip && tooltipSortByMetric) {
return forecastValue
.slice()
.sort((a, b) => b.data[yIndex] - a.data[yIndex])
.map(value => value[TOOLTIP_SERIES_KEY]);
}
if (richTooltip) {
return forecastValue.map(s => s[TOOLTIP_SERIES_KEY]);
}
return [forecastValue[0][TOOLTIP_SERIES_KEY]];
}