fix: Pie chart center number now shows correct count for selected status
This commit is contained in:
@@ -540,9 +540,9 @@ export default function Dashboard() {
|
||||
<Label
|
||||
content={({ viewBox }) => {
|
||||
if (viewBox && 'cx' in viewBox && 'cy' in viewBox) {
|
||||
const activePieIndex = data.orderStatusDistribution.findIndex((item: any) => item.name === activeStatus);
|
||||
const activePieIndex = sortedOrderStatus.findIndex((item: any) => (item.status || item.name) === activeStatus);
|
||||
const displayIndex = hoverIndex !== undefined ? hoverIndex : (activePieIndex >= 0 ? activePieIndex : 0);
|
||||
const selectedData = data.orderStatusDistribution[displayIndex];
|
||||
const selectedData = sortedOrderStatus[displayIndex];
|
||||
return (
|
||||
<text
|
||||
x={viewBox.cx}
|
||||
@@ -555,14 +555,14 @@ export default function Dashboard() {
|
||||
y={viewBox.cy}
|
||||
className="fill-foreground text-3xl font-bold"
|
||||
>
|
||||
{(selectedData?.value ?? 0).toLocaleString()}
|
||||
{(selectedData?.count ?? 0).toLocaleString()}
|
||||
</tspan>
|
||||
<tspan
|
||||
x={viewBox.cx}
|
||||
y={(viewBox.cy || 0) + 24}
|
||||
className="fill-muted-foreground text-sm"
|
||||
>
|
||||
{selectedData?.name}
|
||||
{selectedData?.status || selectedData?.name}
|
||||
</tspan>
|
||||
</text>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user