BarChart: fix hover overlay for hz stacked (#59359)

This commit is contained in:
Leon Sorokin 2022-11-28 06:29:00 -06:00 committed by GitHub
parent b0e886840d
commit 13d5ad2ce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -459,16 +459,21 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) {
let isHovered = hRect && seriesIdx === hRect.sidx;
let heightReduce = 0;
let widthReduce = 0;
// get height of bar rect at same index of the series below the hovered one
if (isStacked && isHovered && hRect!.sidx > 1) {
if (isXHorizontal) {
heightReduce = findRect(qt, hRect!.sidx - 1, hRect!.didx)!.h;
} else {
widthReduce = findRect(qt, hRect!.sidx - 1, hRect!.didx)!.w;
}
}
return {
left: isHovered ? hRect!.x / devicePixelRatio : -10,
left: isHovered ? (hRect!.x + widthReduce) / devicePixelRatio : -10,
top: isHovered ? hRect!.y / devicePixelRatio : -10,
width: isHovered ? hRect!.w / devicePixelRatio : 0,
width: isHovered ? (hRect!.w - widthReduce) / devicePixelRatio : 0,
height: isHovered ? (hRect!.h - heightReduce) / devicePixelRatio : 0,
};
},