From 6e8be826ba7305bee44314391a20a95dc7226c26 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 27 Jan 2023 14:53:45 +0000 Subject: [PATCH] [v9.3.x] StateTimeline: Show correct legend label when value mappings set (#62312) StateTimeline: Show correct legend label when value mappings set (#62282) * StateTimeline: Show correct legend label when value mappings set * Add test dashboard for thresholds and value mappings * run stripnulls.sh (cherry picked from commit 846acd28ff633ce3817def64f4ce9f6b76d6e957) Co-authored-by: Victor Marin <36818606+mdvictor@users.noreply.github.com> --- public/app/plugins/panel/state-timeline/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/state-timeline/utils.ts b/public/app/plugins/panel/state-timeline/utils.ts index fadd2343c9f..40b70442a01 100644 --- a/public/app/plugins/panel/state-timeline/utils.ts +++ b/public/app/plugins/panel/state-timeline/utils.ts @@ -522,9 +522,10 @@ export function getFieldLegendItem(fields: Field[], theme: GrafanaTheme2): VizLe const items: VizLegendItem[] = []; const fieldConfig = fields[0].config; const colorMode = fieldConfig.color?.mode ?? FieldColorModeId.Fixed; + const thresholds = fieldConfig.thresholds; // If thresholds are enabled show each step in the legend - if (colorMode === FieldColorModeId.Thresholds) { + if (colorMode === FieldColorModeId.Thresholds && thresholds?.steps && thresholds.steps.length > 1) { return getThresholdItems(fieldConfig, theme); }