Constructor
Creates a new pie series instance.Properties
Array of pie data entries. Each entry has
label, value, and optional color.Name of the series displayed in the legend.
Array of default colors used for slices when individual colors are not specified.
Inner radius as a fraction of outer radius (0-1). Set to 0 for pie chart, >0 for donut chart.
Whether to show percentage labels on slices (only for slices >5%).
Whether to show the legend below the chart.
Whether animations are enabled for this series.
Duration of animations in milliseconds.
Methods
setData
Updates the pie data and triggers animation if enabled.Array of pie data entries.
render
Renders the pie series on the canvas. Called automatically during the chart render cycle.enableAnimation
Enables animation for the series with an optional custom duration.Animation duration in milliseconds.
disableAnimation
Disables animation for the series.startAnimation
Manually triggers the render animation.getDataAt
Returns the pie slice data at the given position if the position is within a slice.Position to query, typically mouse coordinates in pixels.
The pie data extended as a Point object if the position is within a slice, or null otherwise.
Data format
Pie series uses a specialized PieData format:PieData interface
Configuration
When using the Chart API, configure pie series through the series config:PieSeriesConfig
Pie vs donut charts
Control the chart type using theinnerRadius property:
- Pie chart
- Donut chart
Standard pie chart with filled center:
Labels and legend
Control visibility of labels and legend:Colors
Colors can be specified per slice or use default colors:colors array based on its index (with wrapping).
Animation
By default, pie series animates on initial render and data updates. The animation:- Uses easeOutCubic easing function
- Draws slices progressively in a clockwise direction
- Starts from the top (12 o’clock position)
- Duration is 600ms by default
- Labels and legend appear after animation completes
Layout
The pie series automatically:- Centers the chart in the available space
- Reserves 60px at the bottom for the legend (if enabled)
- Sizes the radius to 75% of available space
- Adapts to container dimensions
Hit testing
ThegetDataAt method performs geometric hit testing:
- Calculates distance from center
- Checks if within outer radius and outside inner radius (for donuts)
- Calculates angle from center
- Determines which slice contains the angle
- Returns the slice data with position information
Use cases
Pie and donut charts are ideal for:- Showing part-to-whole relationships
- Displaying market share or composition
- Visualizing budget allocation
- Representing survey results
- Comparing proportions (3-7 categories recommended)