From 12fc64b389cd726944757339cc7f077f84249d06 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:00:33 +0200 Subject: [PATCH] [v9.2.x] BarChart: fix hover overlay for hz stacked (#59397) BarChart: fix hover overlay for hz stacked (#59359) (cherry picked from commit 13d5ad2ce2a7283dc25dace1328cbf0c11fec639) Co-authored-by: Leon Sorokin --- public/app/plugins/panel/barchart/bars.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/panel/barchart/bars.ts b/public/app/plugins/panel/barchart/bars.ts index 119d8e22ae0..e7a3b17dd5a 100644 --- a/public/app/plugins/panel/barchart/bars.ts +++ b/public/app/plugins/panel/barchart/bars.ts @@ -457,16 +457,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) { - heightReduce = findRect(qt, hRect!.sidx - 1, hRect!.didx)!.h; + 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, }; },