From dff451992d1f3fbb9b00b7c8842a46357e091246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 13 Nov 2020 10:32:08 +0100 Subject: [PATCH] Graph: Fixes stacking issues like floating bars when data is not aligned (#29051) * Graph: Remove interpolation logic from graph stacking * Improving tooltip --- public/app/plugins/panel/graph/graph_tooltip.ts | 16 +++++----------- public/vendor/flot/jquery.flot.stack.js | 4 ++-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/public/app/plugins/panel/graph/graph_tooltip.ts b/public/app/plugins/panel/graph/graph_tooltip.ts index 805cf12d0cb..17c52c180d2 100644 --- a/public/app/plugins/panel/graph/graph_tooltip.ts +++ b/public/app/plugins/panel/graph/graph_tooltip.ts @@ -102,17 +102,11 @@ export default function GraphTooltip(this: any, elem: any, dashboard: any, scope minTime = pointTime; } - if (series.stack) { - if (panel.tooltip.value_type === 'individual') { - value = series.data[hoverIndex][1]; - } else if (!series.stack) { - value = series.data[hoverIndex][1]; - } else { - lastValue += series.data[hoverIndex][1]; - value = lastValue; - } - } else { - value = series.data[hoverIndex][1]; + value = series.data[hoverIndex][1]; + + if (series.stack && value !== null && panel.tooltip.value_type !== 'individual') { + lastValue += value; + value = lastValue; } // Highlighting multiple Points depending on the plot type diff --git a/public/vendor/flot/jquery.flot.stack.js b/public/vendor/flot/jquery.flot.stack.js index 267d4e51642..36ec248d632 100644 --- a/public/vendor/flot/jquery.flot.stack.js +++ b/public/vendor/flot/jquery.flot.stack.js @@ -134,7 +134,7 @@ charts or filled areas). // we got past point below, might need to // insert interpolated extra point if (i > 0 && points[i - ps] != null) { - intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px); + intery = 0; newpoints.push(qx); newpoints.push(intery + qy); for (m = 2; m < ps; ++m) @@ -151,7 +151,7 @@ charts or filled areas). // we might be able to interpolate a point below, // this can give us a better y if (j > 0 && otherpoints[j - otherps] != null) - bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx); + bottom = 0; newpoints[l + accumulateOffset] += bottom;