mirror of
https://github.com/apache/superset.git
synced 2026-04-22 09:35:23 +00:00
fix(plugin-chart-echarts): sort tooltip correctly (#30819)
This commit is contained in:
@@ -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]];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user