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
|
<Label
|
||||||
content={({ viewBox }) => {
|
content={({ viewBox }) => {
|
||||||
if (viewBox && 'cx' in viewBox && 'cy' in 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 displayIndex = hoverIndex !== undefined ? hoverIndex : (activePieIndex >= 0 ? activePieIndex : 0);
|
||||||
const selectedData = data.orderStatusDistribution[displayIndex];
|
const selectedData = sortedOrderStatus[displayIndex];
|
||||||
return (
|
return (
|
||||||
<text
|
<text
|
||||||
x={viewBox.cx}
|
x={viewBox.cx}
|
||||||
@@ -555,14 +555,14 @@ export default function Dashboard() {
|
|||||||
y={viewBox.cy}
|
y={viewBox.cy}
|
||||||
className="fill-foreground text-3xl font-bold"
|
className="fill-foreground text-3xl font-bold"
|
||||||
>
|
>
|
||||||
{(selectedData?.value ?? 0).toLocaleString()}
|
{(selectedData?.count ?? 0).toLocaleString()}
|
||||||
</tspan>
|
</tspan>
|
||||||
<tspan
|
<tspan
|
||||||
x={viewBox.cx}
|
x={viewBox.cx}
|
||||||
y={(viewBox.cy || 0) + 24}
|
y={(viewBox.cy || 0) + 24}
|
||||||
className="fill-muted-foreground text-sm"
|
className="fill-muted-foreground text-sm"
|
||||||
>
|
>
|
||||||
{selectedData?.name}
|
{selectedData?.status || selectedData?.name}
|
||||||
</tspan>
|
</tspan>
|
||||||
</text>
|
</text>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user