Usage
Props
Data and keys
array
The source data array. Each element in the data array represents one sector of the pie.
DataKey<any>
default:"value"
The key of a group of data which should be unique in a pie chart.Can be a string, number, function, or array path.
DataKey<any>
default:"name"
The key of the name property in the data. Used for tooltips and legends.Can be a string, number, function, or array path.
Position and dimensions
number | string
default:"50%"
The x-coordinate of the pie center.If set as a percentage, the final value is obtained by multiplying the percentage with the container width.
number | string
default:"50%"
The y-coordinate of the pie center.If set as a percentage, the final value is obtained by multiplying the percentage with the container height.
number | string
default:"0"
The inner radius of the sectors.If set as a percentage, the final value is obtained by multiplying the percentage with maxRadius.
Set to a positive value to create a donut chart.
number | string | function
default:"80%"
The outer radius of the sectors.If set as a percentage, the final value is obtained by multiplying the percentage with maxRadius.
Can also be a function that receives a data point and returns a number or string.
number
default:"0"
The starting angle of the first sector, in degrees.
number
default:"360"
The ending angle of the last sector, in degrees.
number
default:"0"
The angle between two adjacent sectors, in degrees.
number | string
The radius of the rounded corners of each sector.
Appearance
string
default:"#808080"
The fill color of the sectors.
string
default:"#fff"
The stroke color of the sectors.
number
The stroke width of the sectors.
Behavior
number
default:"0"
The minimum angle of each non-zero data sector, in degrees.Useful for ensuring small values are still visible.
boolean
default:"false"
If true, the pie will not be rendered.Hidden elements are still visible in the legend and can be included in axis domain calculations.
Labels
boolean | object | ReactElement | function
default:"false"
Renders one label for each pie sector.Options:
true: renders default labelsfalse: no labels are renderedobjectwithpositionprop: props for LabelList componentobjectwithoutpositionprop: props for custom Pie label with optional labelLineReactElement: custom label elementfunction: render function for custom label
boolean | object | ReactElement | function
default:"true"
Controls the line connecting each label to its sector.Options:
false: no label linestrue: default label linesobject: props for the label line path elementReactElement: custom label line elementfunction: render function for custom label line
Custom shapes
ReactNode | function
Custom shape for rendering pie sectors.Can be a React element or a function that receives sector props and returns a React element.
The function receives
isActive prop to distinguish active sectors.ActiveShape
deprecated
Deprecated. Use the
shape prop instead. isActive designates the active shape.Custom shape rendered when a sector is activated (by mouse hover, keyboard, etc.).ActiveShape
deprecated
Deprecated. Use the
shape prop instead.Custom shape for inactive sectors.Animation
boolean | 'auto'
default:"auto"
If false, animation will be disabled.If “auto”, animation is disabled in SSR and respects the user’s prefers-reduced-motion preference.
number
default:"400"
Specifies when the animation should begin, in milliseconds.
number
default:"1500"
Specifies the duration of animation, in milliseconds.
string
default:"ease"
The type of easing function.Options: ‘ease’, ‘ease-in’, ‘ease-out’, ‘ease-in-out’, ‘linear’
function
Callback fired when animation starts.
function
Callback fired when animation ends.
Display
LegendType
default:"rect"
The type of icon in the legend.Options: ‘line’, ‘plainline’, ‘square’, ‘rect’, ‘circle’, ‘cross’, ‘diamond’, ‘star’, ‘triangle’, ‘wye’, ‘none’
TooltipType
Valid tooltip types for this graphical item.
number
default:"100"
The z-index of the pie sectors.Higher values render on top of lower values.
Interaction
function
Event handler for click events on sectors.Signature:
(data: PieSectorDataItem, index: number, e: React.MouseEvent) => voidfunction
Event handler for mouse enter events on sectors.
function
Event handler for mouse leave events on sectors.
function
Event handler for mouse move events on sectors.
Other
string
Unique identifier for this pie instance.
string
CSS class name for the pie element.
number
default:"0"
The tabindex attribute of the wrapper element surrounding the sectors.