Docs
📊 ⏐ Charts
Pie Chart

Pie Chart

A Pie Chart in REAVIZ is divided into sectors, each representing a numerical proportion. The arc length of each sector (along with its central angle and area) is proportional to the quantity it represents. Named for its resemblance to a sliced pie, a pie chart effectively visualizes part-to-whole relationships in data.

Types supported by reaviz:

  • Pie - A standard pie chart divided into sectors to show proportions.
  • Exploded - A variation where one or more slices are separated from the main chart to emphasize specific sectors.
  • Donut - Similar to a pie chart, but with a hole in the center, making it easier to read multiple data points.

Where to use:

  • Show Proportions: Ideal for visualizing parts of a whole.
  • Compare Categories: Useful for comparing different categories in a dataset.
  • Highlight Key Data Points: Exploded pie charts emphasize specific sectors.

Quick Start

To create a Pie chart, use import the PieChart and give it data. The chart will automatically configure itself with the default options exposed via props.

Examples

Pie

Exploded

Donut

API

PieChart (opens in a new tab)

PropDescriptionDefault
dataData the chart will receive to render.
ChartShallowDataShape<ChartDataTypes | [ChartDataTypes, ChartDataTypes]>[]
[]
disabledWhether the chart is disabled.
boolean
displayAllLabelsWhether to display labels even if their value has a small display radius.
boolean
seriesThe series component that renders the arc components.
ReactElement<PieArcSeriesProps, FC<Partial<PieArcSeriesProps>>>
<PieArcSeries />
idId of the chart.
string
widthWidth of the chart. If not provided will autosize.
number
heightHeight of the chart. If not provided will autosize.
number
marginsMargins for the chart.
Margins
10
classNameClassnames for the chart.
string
containerClassNameClassnames for the chart.
string
styleAdditional css styles.
StyleHTMLAttributes<SVGSVGElement>
centerCenter the chart. Used mainly internally.
boolean
centerXCenter chart on X Axis only. Used mainly internally.
boolean
centerYCenter chart on Y Axis only. Used mainly internally.
boolean

PieArcSeries (opens in a new tab)

PropDescriptionDefault
idUnique id for the series.
string
animatedAnimated set by the `PieArc` components.
boolean
true
outerRadiusOuter radius set by the parent component.
number
innerRadiusInner radius set by the parent component.
number
0
padAnglePad Angle between adjacent arcs, see https://github.com/d3/d3-shape#arc_padAngle
number
0
padRadiusPad Radius between adjacent arcs, see https://github.com/d3/d3-shape#arc_padRadius
number
0
cornerRadiusCorner Radius of the arcs, see https://github.com/d3/d3-shape#arc_cornerRadius
number
0
dataData set by the parent component.
ArcData[]
arcWidthWidth of the arc
number
0.25
doughnutDoughnut, render as a donut shape
boolean
explodeExplode: OuterRadius will be adjusted by the data property
boolean
false
displayAllLabelsDisplay all labels shows labels even if there is little space
boolean
false
labelLabel component
ReactElement<PieArcLabelProps, FC<Partial<PieArcLabelProps>>>
<PieArcLabel />
arcArc Component
ReactElement<PieArcProps, FC<PieArcProps>>
<PieArc />
colorSchemeColor scheme
ColorSchemeType
cybertron
heightHeight set by the parent component
number
widthWidth set by the parent component
number

PieArcLabel (opens in a new tab)

PropDescriptionDefault
dataData set by the parent component
ArcData
centroidA function returning the centroid of the corresponding `PieArc` @param d PieArcDatum
(d: ArcData) => [number, number]
formatA Formatting function for the label value @param v The label value
(v: any) => ReactNode
undefined
fontFillFontFill color
string
#8F979F
fontSizeFontSize
number
11
fontFamilyFontFamily
string
sans-serif
lineStrokeLine stroke of the label connector
string
rgba(127,127,127,0.5)
outerRadiusOuter radius of the corresponding `PieArc`
number
paddingy Padding of the label
string
.35em
positionThe label position set by the parent component
[number, number]
widthWidth of the label
number
heightHeight of the label
number
11

PieArc (opens in a new tab)

PropDescriptionDefault
idUnique id for arc
string
arcThe arc generator function returning an arc path @param data
(data: ArcData) => string
dataData is the datum passed to the arc generator function
ArcData
colorColor
string
animatedAnimate
boolean
true
tooltipTooltip component
ReactElement<ChartTooltipProps, FC<Partial<ChartTooltipProps>>>
<ChartTooltip />
cursorThe cursor type used when hovering
string
initial
disabledDisable the arc
boolean
false
gradientGradient shades for the bar.
ReactElement<GradientProps, FC<Partial<GradientProps>>>
onClickOnClick event handler @param e Click event
(e: PieArcMouseEvent) => void
onMouseEnterMouseEnter event handler @param e MouseEnter event
(e: PieArcMouseEvent) => void
onMouseLeaveMouseLeave event handler @param e MouseLeave event
(e: PieArcMouseEvent) => void