PiePlot
Builder for creating pie or donut charts. Each slice has its own explicit color. Slice labels can be positioned automatically, forced inside or outside, or suppressed entirely in favor of a legend. Percentage values can be appended to labels withwith_percent().
Render with render_pie for most cases, or render_multiple when a legend is attached.
Constructor
Create a pie chart with default settings.Defaults:
- Full pie (
inner_radius = 0.0) - Auto label positioning
- No percentages
- No legend
min_label_fraction = 0.05(5%)
Data Methods
Styling Methods
0.0 (the default) renders a solid pie. Any positive value cuts a hollow centre. Typical values are in the range 40.0–80.0 depending on the canvas size.Example:Label Methods
PieLabelPosition for the available options. The default is Auto."Rust 40.0%").fraction of the total are silently skipped. The default is 0.05 (5%). Set to 0.0 to label every slice regardless of size.Example:Legend Methods
render_multiple adds a per-slice legend entry (colored square + slice label) in the right margin. Combine with with_label_position(PieLabelPosition::None) to use the legend as the sole means of identification.Example:Enums & Types
PieLabelPosition
Controls where slice labels are placed relative to each slice. Default isAuto.
Inside- Labels centered between the inner and outer radius (or at mid-radius for a full pie). Works well when all slices are large enough to fit text.Outside- Labels placed outside the pie with leader lines connecting them to their slice. Small slices are automatically spaced to avoid label overlap.Auto- Inside for large slices; outside with a leader line for small ones. This is the default. The threshold is controlled bywith_min_label_fraction.None- No slice labels. Combine withwith_legendto identify slices via a legend instead.
PieSlice
A single slice of a pie chart. Fields:label: String- Slice labelvalue: f64- Slice value (proportional)color: String- Fill color (CSS color string)