feat: display revenue as currency in PieChart tooltip
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m12s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m12s
This commit is contained in:
@@ -11,13 +11,20 @@ const COLORS = [
|
||||
'#06b6d4', '#ec4899', '#eab308', '#6366f1', '#14b8a6'
|
||||
];
|
||||
|
||||
const CustomTooltip = ({ active, payload, label }: any) => {
|
||||
const formatCurrency = (value: number) => {
|
||||
return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(value);
|
||||
};
|
||||
|
||||
const CustomTooltip = ({ active, payload, label, isCurrency }: any) => {
|
||||
if (active && payload && payload.length) {
|
||||
const color = payload[0].payload?.fill || payload[0].color || '#9ECAE1';
|
||||
const displayLabel = label || payload[0].name;
|
||||
const value = isCurrency ? formatCurrency(payload[0].value) : payload[0].value;
|
||||
const valueLabel = isCurrency ? 'Receita:' : 'Vendas:';
|
||||
return (
|
||||
<div className="bg-[#141414] p-3 rounded-xl shadow-lg border-none">
|
||||
<p className="font-bold mb-1" style={{ color }}>{label}</p>
|
||||
<p className="text-[#ededed] m-0">Vendas: {payload[0].value}</p>
|
||||
<p className="font-bold mb-1" style={{ color }}>{displayLabel}</p>
|
||||
<p className="text-[#ededed] m-0">{valueLabel} {value}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user