From a417402c778045ae39e6b462d4d9d7fea1e55c78 Mon Sep 17 00:00:00 2001 From: Nathan Marrs Date: Tue, 3 Oct 2023 17:50:57 +0200 Subject: [PATCH] Legend: Fix desc sort so NaNs are not display first (#75685) do not put NaNs as first in legend desc sort Co-authored-by: Simon Podlipsky Co-authored-by: Adela Almasan --- .../grafana-ui/src/components/VizLegend/VizLegendTable.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx index 01e07e71e56..a8c29c7d10e 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx @@ -53,7 +53,10 @@ export const VizLegendTable = ({ if (item.getDisplayValues) { const stat = item.getDisplayValues().filter((stat) => stat.title === sortKey)[0]; - return stat && stat.numeric; + + if (stat) { + return isNaN(stat.numeric) ? -Infinity : stat.numeric; + } } return undefined; },