PieChart: Respect percent labels and legends decimal setting (#43693)

This commit is contained in:
Oscar Kilhed 2022-01-05 10:24:43 +01:00 committed by GitHub
parent 837925390f
commit 1d20c82c7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -299,7 +299,7 @@ function PieLabel({ arc, outerRadius, innerRadius, displayLabels, total, color,
)}
{displayLabels.includes(PieChartLabels.Percent) && (
<tspan x={labelX} dy="1.2em">
{((arc.data.display.numeric / total) * 100).toFixed(0) + '%'}
{((arc.data.display.numeric / total) * 100).toFixed(arc.data.field.decimals ?? 0) + '%'}
</tspan>
)}
</text>

View File

@ -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' : '',
});
}