fix: Incorrect hovered items in tooltips (#30405)
This commit is contained in:
parent
0fdcd8b27e
commit
36f7a3f524
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue