Skip to main content

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​

Props
innerRadius
startAngle
endAngle
padAngle
legendPosition
design
<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>

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:

PropTypeDefaultDescription
nameKeystring—The row field naming each slice.
valueKeystring—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.
innerRadiusnumber0 (pie), 0.62 (donut)The hole, as a share of the radius.
startAnglenumber0Degrees clockwise from 12 o'clock.
endAnglenumber360-90 to 90 is a half donut.
padAnglenumber0.7Degrees between slices.
showLabelsbooleanfalseEach slice's share outside it.
defaultHiddenstring[]—Slices left out at first; the legend brings them back.
centerLabelstring—DonutChart: under the total.
centerValuestringthe totalDonutChart: in the hole instead of the total, e.g. '730K'.