Charts
Donut chart
Six slices at most; the rest fold into Other. Hover a slice or a legend row.
How people paid
Today
৳46,690
- Cash at the gate৳18,45040%
- bKash৳12,32026%
- Nagad৳6,11013%
- Card৳4,3809.4%
- ParkingOS wallet৳2,9606.3%
- Other৳2,4705.3%
donut-chart.tsx
"use client";
import { ChartCard, DonutChart } from "@waveinno/ui";
export default function DonutChartExample() {
return (
<ChartCard title="How people paid" height={230}>
<DonutChart
data={[
{ id: "cash", label: "Cash at the gate", value: 18450 },
{ id: "bkash", label: "bKash", value: 12320 },
{ id: "nagad", label: "Nagad", value: 6110 },
{ id: "card", label: "Card", value: 4380 },
{ id: "wallet", label: "ParkingOS wallet", value: 2960 },
{ id: "monthly", label: "Monthly pass", value: 1520 },
{ id: "voucher", label: "Voucher", value: 640 },
{ id: "other", label: "Bank transfer", value: 310 },
]}
format={(v) => `৳${v.toLocaleString()}`}
centerLabel="Today"
/>
</ChartCard>
);
}Import#
Everything comes from the package root. The example above uses:
your-component.tsx
import { ChartCard, DonutChart } from "@waveinno/ui";Props#
Read from the source of this version, so they match the code exactly.
<DonutChart>
src/components/charts/donut-chart.tsx| Prop | Type | Default | Description |
|---|---|---|---|
datarequired | DonutDatum[] | — | |
format | (v: number) => string | (v) => v.toLocaleString() | |
centerLabel | string | "Total" | |
centerValue | React.ReactNode | — | Shown in the hole; defaults to the formatted total. |
maxSlices | number | 6 | |
otherLabel | string | "Other" | |
height | number | 220 | |
legend | "right" | "bottom" | "none" | "right" | |
className | string | — |
<ChartCard>
src/components/charts/chart-card.tsx| Prop | Type | Default | Description |
|---|---|---|---|
titlerequired | string | — | |
description | string | — | |
series | SeriesMeta[] | — | |
action | React.ReactNode | — | |
childrenrequired | React.ReactNode | — | |
className | string | — | |
height | number | 240 |
Install#
If the project does not have the package yet, add it, then follow the setup for Next.js or Vite once.
$ npm install @waveinno/ui