From 1d20c82c7ba6d05a81999b0ebc5409adb0c9c965 Mon Sep 17 00:00:00 2001 From: Oscar Kilhed Date: Wed, 5 Jan 2022 10:24:43 +0100 Subject: [PATCH] PieChart: Respect percent labels and legends decimal setting (#43693) --- public/app/plugins/panel/piechart/PieChart.tsx | 2 +- public/app/plugins/panel/piechart/PieChartPanel.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panel/piechart/PieChart.tsx b/public/app/plugins/panel/piechart/PieChart.tsx index c0d53ec1a16..f264034a7bd 100644 --- a/public/app/plugins/panel/piechart/PieChart.tsx +++ b/public/app/plugins/panel/piechart/PieChart.tsx @@ -299,7 +299,7 @@ function PieLabel({ arc, outerRadius, innerRadius, displayLabels, total, color, )} {displayLabels.includes(PieChartLabels.Percent) && ( - {((arc.data.display.numeric / total) * 100).toFixed(0) + '%'} + {((arc.data.display.numeric / total) * 100).toFixed(arc.data.field.decimals ?? 0) + '%'} )} diff --git a/public/app/plugins/panel/piechart/PieChartPanel.tsx b/public/app/plugins/panel/piechart/PieChartPanel.tsx index b8e87a8cd72..a1ba2a08a3a 100644 --- a/public/app/plugins/panel/piechart/PieChartPanel.tsx +++ b/public/app/plugins/panel/piechart/PieChartPanel.tsx @@ -123,7 +123,7 @@ function getLegend(props: Props, displayValues: FieldDisplay[]) { text: hidden || isNaN(fractionOfTotal) ? props.fieldConfig.defaults.noValue ?? '-' - : percentOfTotal.toFixed(0) + '%', + : percentOfTotal.toFixed(value.field.decimals ?? 0) + '%', title: valuesToShow.length > 1 ? 'Percent' : '', }); }