From 717859a1f4fdc7fc1766530495c484e4de573b52 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:26:15 -0400 Subject: [PATCH] [v10.0.x] Barchart: Fix tooltip for normal/percentage stacking(2) (#70027) Barchart: Fix tooltip for normal/percentage stacking(2) (#69956) (cherry picked from commit 9e198ba7457f7d560418f262085e9ec3822bec1d) Co-authored-by: Adela Almasan <88068998+adela-almasan@users.noreply.github.com> --- public/app/plugins/panel/barchart/bars.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/panel/barchart/bars.ts b/public/app/plugins/panel/barchart/bars.ts index 4da1b53454c..b20eb53c424 100644 --- a/public/app/plugins/panel/barchart/bars.ts +++ b/public/app/plugins/panel/barchart/bars.ts @@ -493,13 +493,15 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) { let heightReduce = 0; let widthReduce = 0; - const rect = hRect && findRect(qt, hRect.sidx - 1, hRect.didx); // get height of bar rect at same index of the series below the hovered one - if (isStacked && isHovered && hRect!.sidx > 1 && rect) { - if (isXHorizontal) { - heightReduce = rect.h; - } else { - widthReduce = rect.w; + if (isStacked && isHovered) { + const rect = hRect && hRect.sidx > 1 && findRect(qt, hRect.sidx - 1, hRect.didx); + if (rect) { + if (isXHorizontal) { + heightReduce = rect.h; + } else { + widthReduce = rect.w; + } } }