Examples
Pie & Donut chart Pro
Parts of a whole. The legend names each slice with its share, and pressing a legend item leaves that slice out (the rest re-share the whole). The slice under the finger or pointer lifts out; in a DonutChart the hole shows it, and the total otherwise. Slices sweep open on mount and turn to new shares when the data changes. startAngle={-90} endAngle={90} draws a half donut.
import { DonutChart, PieChart } from '@patine-ui/pro';
Live data
Loading…
<View style={{ width: 360, gap: 8 }}> <Button size="sm" variant="outline" onPress={() => setData(roll())} style={{ alignSelf: 'flex-end' }}>Shuffle</Button> <DonutChart data={data} nameKey="browser" valueKey="visitors" centerLabel="Visitors" valueFormat="compact" height={220} accessibilityLabel="Visitors by browser" /> </View>
Try the props
innerRadiusstartAngleendAnglepadAnglelegendPositiondesign<DonutChart
data={browsers}
nameKey="browser"
valueKey="visitors"
centerLabel="Visitors"
/>
Example: where the money went
A budgeting app's month: each category's share of spending, the total in the hole, and Savings hidden at first so the chart shows only what was spent. Press it in the legend to add it.
Loading…
<View style={{ width: '100%', maxWidth: 520, gap: 8 }}> <Text weight="semibold">October</Text> <DonutChart data={SPENT} nameKey="category" valueKey="amount" centerLabel="Spent" valueFormatter={(v) => `€${v.toLocaleString()}`} defaultHidden={['Savings']} showLabels height={260} accessibilityLabel="Spending by category in October" /> </View>
Gallery
Half donut
Loading…
<DonutChart data={data} nameKey="plan" valueKey="users" startAngle={-90} endAngle={90} innerRadius={0.7} centerLabel="Users" valueFormat="compact" height={180} style={{ width: 340 }} />
Pie with labels
Loading…
<PieChart data={data} nameKey="category" valueKey="spent" showLabels valueFormat="currency" legendPosition="top" height={240} style={{ width: 360 }} />
Props
The shared chart props, and:
| Prop | Type | Default | Description |
|---|---|---|---|
nameKey | string | — | The row field naming each slice. |
valueKey | string | — | The row field with each slice's value. Zero, negative and missing values get no slice. |
series | { key, label?, color? }[] | — | Labels and colors, matched to nameKey. |
innerRadius | number | 0 (pie), 0.62 (donut) | The hole, as a share of the radius. |
startAngle | number | 0 | Degrees clockwise from 12 o'clock. |
endAngle | number | 360 | -90 to 90 is a half donut. |
padAngle | number | 0.7 | Degrees between slices. |
showLabels | boolean | false | Each slice's share outside it. |
defaultHidden | string[] | — | Slices left out at first; the legend brings them back. |
centerLabel | string | — | DonutChart: under the total. |
centerValue | string | the total | DonutChart: in the hole instead of the total, e.g. '730K'. |