From 45a08792befad7f944ea317686758ff7337730bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Wed, 16 Jan 2019 09:27:46 +0100 Subject: [PATCH] Fixed small bug with entries outside the min max values --- .../src/components/ThresholdsEditor/ThresholdsEditor.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx b/packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx index 9fee8025ec3..6e8d88051f3 100644 --- a/packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx +++ b/packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx @@ -42,10 +42,10 @@ export class ThresholdsEditor extends PureComponent { }); // Setting value to a value between the previous thresholds - const beforeThreshold = newThresholds.filter(threshold => threshold.index === index - 1)[0]; - const afterThreshold = newThresholds.filter(threshold => threshold.index === index + 1)[0]; - const beforeThresholdValue = beforeThreshold !== undefined ? Math.max(beforeThreshold.value, minValue) : minValue; - const afterThresholdValue = afterThreshold !== undefined ? Math.min(afterThreshold.value, maxValue) : maxValue; + const beforeThreshold = newThresholds.filter(t => t.index === index - 1 && t.index !== 0)[0]; + const afterThreshold = newThresholds.filter(t => t.index === index + 1 && t.index !== 0)[0]; + const beforeThresholdValue = beforeThreshold !== undefined ? beforeThreshold.value : minValue; + const afterThresholdValue = afterThreshold !== undefined ? afterThreshold.value : maxValue; const value = afterThresholdValue - (afterThresholdValue - beforeThresholdValue) / 2; // Set a color