From 586b89f7767a937133fc71ea945de97edcea23fc Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Thu, 10 Feb 2022 11:49:30 -0600 Subject: [PATCH] Thresholds: fix crash when trying to render zero-height base thresholds (#45256) --- .../grafana-ui/src/components/uPlot/config/gradientFills.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts b/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts index c3daf47fb0a..f1443c6d587 100644 --- a/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts +++ b/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts @@ -134,6 +134,10 @@ export function scaleGradient(u: uPlot, scaleKey: string, scaleStops: ScaleValue let range = minStopPos - maxStopPos; + if (range === 0) { + return scaleStops[maxStopIdx!][1]; + } + let x0, y0, x1, y1; if (u.scales.x!.ori === ScaleOrientation.Horizontal) {