diff --git a/public/app/plugins/panel/piechart/PieChartPanel.tsx b/public/app/plugins/panel/piechart/PieChartPanel.tsx index 236b31f6cd7..8e93d529262 100644 --- a/public/app/plugins/panel/piechart/PieChartPanel.tsx +++ b/public/app/plugins/panel/piechart/PieChartPanel.tsx @@ -87,7 +87,15 @@ function getLegend(props: Props, displayValues: FieldDisplay[]) { const legendItems = displayValues // Since the pie chart is always sorted, let's sort the legend as well. - .sort((a, b) => b.display.numeric - a.display.numeric) + .sort((a, b) => { + if (isNaN(a.display.numeric)) { + return 1; + } else if (isNaN(b.display.numeric)) { + return -1; + } else { + return b.display.numeric - a.display.numeric; + } + }) .map((value, idx) => { const hidden = value.field.custom.hideFrom.viz; const display = value.display;