Skip to Content

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Β 

NameTypeDefault
dataChartShallowDataShape[]

Data the chart will receive to render.

[]
disabledboolean

Whether the chart is disabled.

displayAllLabelsboolean

Whether to display labels even if their value has a small display radius.

seriesReactElement<PieArcSeriesProps, FC<Partial<PieArcSeriesProps>>>

The series component that renders the arc components.

`<PieArcSeries />`
idstring

Id of the chart.

widthnumber

Width of the chart. If not provided will autosize.

heightnumber

Height of the chart. If not provided will autosize.

marginsMargins

Margins for the chart.

classNamestring

Classnames for the chart.

containerClassNamestring

Classnames for the chart.

styleStyleHTMLAttributes<SVGSVGElement>

Additional css styles.

centerboolean

Center the chart. Used mainly internally.

centerXboolean

Center chart on X Axis only. Used mainly internally.

centerYboolean

Center chart on Y Axis only. Used mainly internally.

PieArcSeriesΒ 

NameTypeDefault
idstring

Unique id for the series.

animatedboolean

Animated set by the PieArc components.

true
outerRadiusnumber

Outer radius set by the parent component.

innerRadiusnumber

Inner radius set by the parent component.

0
padAnglenumber

Pad Angle between adjacent arcs, see https://github.com/d3/d3-shape#arc_padAngleΒ 

0
padRadiusnumber

Pad Radius between adjacent arcs, see https://github.com/d3/d3-shape#arc_padRadiusΒ 

0
cornerRadiusnumber0
dataArcData[]

Data set by the parent component.

arcWidthnumber

Width of the arc

0.25
doughnutboolean

Doughnut, render as a donut shape

explodeboolean

Explode: OuterRadius will be adjusted by the data property

false
displayAllLabelsboolean

Display all labels shows labels even if there is little space

false
labelReactElement<PieArcLabelProps, FC<Partial<PieArcLabelProps>>> | null

Label component

`<PieArcLabel />`
arcReactElement<PieArcProps, FC<PieArcProps>>

Arc Component

`<PieArc />`
colorSchemeColorSchemeType

Color scheme

'cybertron'
heightnumber

Height set by the parent component

widthnumber

Width set by the parent component

PieArcLabelΒ 

NameTypeDefault
dataArcData

Data set by the parent component

centroid(d: ArcData) => [number, number]

A function returning the centroid of the corresponding PieArc

format(v: any) => ReactNode

A Formatting function for the label value

fontFillstring

FontFill color

'#8F979F'
fontSizenumber

FontSize

11
fontFamilystring

FontFamily

'sans-serif'
lineStrokestring

Line stroke of the label connector

'rgba(127,127,127,0.5)'
outerRadiusnumber

Outer radius of the corresponding PieArc

paddingstring

y Padding of the label

'.35em'
position[number, number]

The label position set by the parent component

widthnumber

Width of the label

heightnumber

Height of the label

11

PieArcΒ 

NameTypeDefault
idstring

Unique id for arc

arc(data: ArcData) => string | null

The arc generator function returning an arc path

dataArcData

Data is the datum passed to the arc generator function

colorstring

Color

animatedboolean

Animate

true
tooltipReactElement<ChartTooltipProps, FC<Partial<ChartTooltipProps>>> | null

Tooltip component

`<ChartTooltip />`
cursorstring

The cursor type used when hovering

'initial'
disabledboolean

Disable the arc

false
gradientReactElement<GradientProps, FC<Partial<GradientProps>>> | null

Gradient shades for the bar.

styleMotionStyle

Style for the arc

onClick(e: PieArcMouseEvent) => void

OnClick event handler

onMouseEnter(e: PieArcMouseEvent) => void

MouseEnter event handler

onMouseLeave(e: PieArcMouseEvent) => void

MouseLeave event handler

Last updated on