Charts - Pie & Donut
Circular charts for part-to-whole relationships. Pie, donut, and gauge variants.
#Usage
import { ChartAnnotation, ChartCanvas, ChartCaption, ChartDataLabels, ChartExportMenu, ChartHover, ChartItem, ChartLegend, ChartPie, ChartStacked, ChartSvg, ChartTitle, ChartTooltip } from '@primeui/vue-chart';<ChartSvg>
<ChartPie :data="data" value-field="valueField" category-field="categoryField" />
</ChartSvg>Pie and donut charts show proportions of a whole, suited for part-to-whole comparisons with a small number of categories. Data binds to ChartPie; no axes are needed. Set innerRadius to switch from pie to donut.
#Basic
Map data fields with valueField and categoryField. The chart calculates each slice angle from the acquisition-channel share.
#Donut
Set innerRadius to cut a hole in the center. The value is a ratio of the outer radius. 0.6 creates a readable account-mix ring, while 0.8 produces a thin ring.
#Gauge
Reduce sweepAngle below 360 to create a gauge arc. Combine with startAngle to set the opening direction. Pair with innerRadius and a muted remainder slice for a compact SLO or error-budget readout.
#Colors
Pass an array to color to define a custom palette. Slices cycle through colors by index, which is useful for stable acquisition channels or product segments. For per-slice control, pass a function that receives each data item and returns a color string.
#Gradient Color
Pass a radial gradient object to color instead of a flat hex value. Each gradient defines stops with offset and color pairs; keep the palette controlled so the effect reads as depth, not decoration.
#Sorted
Set sort to reorder slices before rendering. Use value-desc to place the largest incident cause first, or label-asc for alphabetical order. Sort does not affect the underlying data, only the visual arrangement.
#Outer Radius
Set outerRadius to control how much of the chart area the pie fills. The default 1 fills the available space. A smaller radius leaves room for external labels and leader lines.
#Variable Radius
Set sliceRadiusValue to a numeric data field to vary each slice's outer radius independently. Use equal angle weights when the categories are cyclical, then let radius carry the magnitude. That shape is known as a Nightingale or rose chart.
#Border
Set borderStrokeWidth and borderColor to add a stroke around each slice. Add borderRadius for rounded corners, spacing to introduce gaps between slices, and borderDash for a dashed stroke.
#Custom Slice Content
Use renderContent to draw custom content inside each slice. The callback receives the slice's value, percentage, label, index, and color. In SVG mode return a VNode centered at the origin. In Canvas mode draw to ctx directly and return null.
#Stacked
Wrap multiple ChartPie components inside ChartStacked to create concentric rings. Use the inner ring for the parent categories and the outer ring for the child split. Set gap on ChartStacked to add spacing between rings.
#Declarative
Define slices inline using ChartItem children instead of a data array. Each ChartItem accepts value, category, color, borderRadius, borderColor, and borderStrokeWidth.
#Title & Caption
Add ChartTitle to display a title above the chart and ChartCaption for a descriptive line beneath it. Adding both reduces the available chart area.
For full configuration see Title & Caption.
#Hover
Add ChartHover to pop the hovered slice outward along its angle. The chart reserves padding so it doesn't clip. Use brightness to lighten the slice and set dimOpacity below 1 only when you want the rest to fade.
For full configuration see Hover.
#Tooltip
Add ChartTooltip to show slice details on hover. The tooltip includes the percentage alongside the value with no extra configuration. Use the render prop for custom tooltip content.
For full configuration see Tooltip.
#Legend
Add ChartLegend to display an interactive legend. For pie charts, each slice gets its own legend entry. Click any item to toggle the corresponding slice. Set position to top, bottom, left, or right.
For full configuration see Legend.
#Data Labels
Add ChartDataLabels to display labels outside the slices with leader lines. Set display to value, percentage, or both. Use minPercentage to hide labels on very small slices and lineStyle to switch between angled and straight connectors.
For full configuration see Data Labels.
#Annotation
Use ChartAnnotation with the render callback to place custom content in the center of a donut. The callback receives chartArea, center, xScale, yScale, textColor, fontFamily, and ctx (Canvas mode only). Use center to position content at the chart's center. xScale and yScale are null for pie charts. In SVG mode return a VNode. In Canvas mode draw to ctx and return null.
For full configuration see Annotation.
#Animation
Pass the chart-root animation prop (<ChartSvg> / <ChartCanvas>) to control entrance and update transitions. Slices expand from zero span on entrance. On data updates, slices interpolate their rotation and angle. Slice additions and removals animate independently.
For full configuration see Animation.
#Export
Add ChartExportMenu to let users download the chart as PNG, SVG, or PDF.
See Export for format options and programmatic export.
#Responsive
See Responsive for container sizing, aspect ratio, and breakpoint configuration.
#Accessibility
See Accessibility for ARIA labels, keyboard navigation, and screen reader support.
#API
#ChartPie
Visual styling props with type accessor → R accept a static value, a per-slice array, a field name (keyof T), or a callback (ctx: ItemContext<T>) => R | undefined. Color-family arrays cycle modulo length; other accessor arrays clip and fall back to the series default.
| Prop | Type | Default | Description |
|---|---|---|---|
data | T[] | - | Data array. Mutually exclusive with ChartItem children |
valueField | accessor → number | 'value' | Numeric value. Determines slice angle |
categoryField | accessor → string | 'category' | Slice label text |
color | accessor → FillValue | default palette | Per-slice colors. Static color, array (cycles by index), field name, or callback. Accepts hex, RGB, CSS variables, and radial gradient objects |
opacity | accessor → number | 1 | Slice fill opacity in [0, 1]. Per-slice via array/callback/field-name. Multiplies into hover/dim effects |
offset | accessor → number | 0 | Per-slice radial offset in pixels. Pulls slices outward from the center (exploded pie effect) |
innerRadius | 0–1 | 0 | Donut hole ratio. 0 = solid pie, 0.6 = hole 60% of the outer radius |
outerRadius | 0–1 | 1 | Outer radius ratio. 1 = fills available space, 0.7 = 70% of chart area |
startAngle | number | -90 | Where slices begin in degrees. -90 = 12 o'clock, 0 = 3 o'clock |
sweepAngle | number | 360 | Arc span in degrees. 360 = full circle, 180 = half-circle gauge |
spacing | number | 0 | Gap between slices (px) |
sliceRadiusValue | accessor → number | - | Per-slice variable outer radius. Creates a Nightingale chart |
sort | 'value-asc' | 'value-desc' | 'label-asc' | 'label-desc' | - | Slice ordering before render |
borderRadius | accessor → BorderRadius | - | Rounded slice corners. Accepts a number or { topLeft, topRight, bottomLeft, bottomRight } |
borderColor | accessor → FillValue | - | Slice border stroke color |
borderStrokeWidth | accessor → number | - | Slice border stroke width (px) |
borderDash | accessor → number[] | - | Dash pattern [dashLength, gapLength]. Also accepts named shortcuts ('solid', 'dashed', 'dotted') |
borderDashOffset | accessor → number | 0 | Offset for the dash pattern |
borderJoinStyle | 'round' | 'bevel' | 'miter' | - | How border segments connect at slice corners |
borderAlign | 'center' | 'inner' | 'inner' | Border alignment relative to the slice edge |
hoverColor | accessor → FillValue | - | Per-slice fill color on hover. Short-circuits the global ChartHover.brightness cascade |
hoverBorderColor | accessor → FillValue | - | Per-slice border color on hover |
renderContent | (context: SliceRenderContext) => unknown | - | Custom content inside each slice. SVG: return a VNode centered at origin. Canvas: draw to ctx and return null |
name | string | - | Dataset label, used in the legend |
order | number | auto | Stacking order for concentric rings. 0 = innermost |
keyField | string | - | Field name for stable item identity. Used for animation matching when data is reordered |
id | string | auto | Unique dataset identifier |
#ItemContext
Passed to every accessor → R callback. Return undefined to fall back to the series-level default for that item.
| Field | Type | Description |
|---|---|---|
datum | T | Original data row |
value | number | null | Resolved numeric value (when applicable) |
index | number | Position within the dataset |
seriesIndex | number | Order of this series within the chart |
seriesId | string | Dataset id |
category | string? | Resolved slice label |
#ChartStacked
Wrap multiple ChartPie components inside ChartStacked to create concentric rings. Each ChartPie child becomes one ring.
| Prop | Type | Default | Description |
|---|---|---|---|
gap | px | 0 | Spacing between concentric rings |
id | string | auto | Stack group identifier |
#ChartItem
Use ChartItem as children of ChartPie instead of a data array for inline slice definitions.
| Prop | Type | Description |
|---|---|---|
value | number | Slice size |
category | string | Slice label |
color | string | Override color for this slice |
borderRadius | BorderRadius | Per-slice corner radius |
borderColor | string | Per-slice border color |
borderStrokeWidth | number | Per-slice border width |
#SliceRenderContext
| Field | Type | Description |
|---|---|---|
index | number | Slice index in the data array |
data | T | Original data item from the data array |
value | number | Numeric slice value |
percentage | number | Percentage of total (0–100) |
label | string | Slice label |
color | string | Resolved fill color |
center | { x: number; y: number } | Center of the pie/donut circle in absolute coordinates. Use for positioning relative to the chart center, for example donut hole labels. Not the same as x/y |
x | number | Midpoint of this slice's arc in absolute coordinates. Use for positioning content inside the slice. Not the same as center |
y | number | Midpoint of this slice's arc in absolute coordinates. See x |
angle | number | Midpoint angle in degrees |
isHovered | boolean | Whether the slice is currently hovered |
isVisible | boolean | Whether the slice is visible (not toggled off via legend) |
ctx | CanvasRenderingContext2D | undefined | Canvas context, present only in Canvas mode |
drawImage | function | undefined | Draw an image from a URL at a position relative to origin. Canvas mode only |
fontFamily | string | Resolved font family for text rendering |