Pie Chart (Pie)
This chapter explains how Pie charts work in EasyChart: how data fields are interpreted, how layout/aggregation/legend/interactions take effect, and which behaviors have hidden prerequisites, mapped to Inspector fields.
1. Use cases
- Showing proportions/composition
- Emphasizing the share of each category in the whole
Not suitable for:
- Too many categories (usually > 8–12 becomes hard to read)
- Precise comparison of tiny differences (a bar chart is usually better)
2. Minimum viable setup (checklist)
coordinateSystem: Pie does not rely on Cartesian/Polar coordinate systems (keep your Profile setting)- Add 1
Serie:type = Piesettings = PieSettingsseriesDatahas at least 1 point
- Ensure each point has
value > 0
Note: Pie currently ignores points with
value <= 0.
3. Important limitations (runtime behavior)
- Only the first visible Pie serie is drawn: the renderer iterates
Data.Series, finds the first visible serie withtype=Pie, draws it, thenbreaks. - Slice hidden state comes from
ChartInteractionState.HiddenPieSliceIds, which is added/removed when clicking legend items.
4. SeriesData field interpretation (runtime behavior)
Pie mainly uses:
value: numeric value (weight) of the slicename: slice name (recommended)useColor + color: per-slice custom color (optional)id: stable slice identifier (for hidden/interaction state; keep it stable)
4.1 Recommended pattern: explicit name + value
SeriesData.name = "Apple"SeriesData.value = 12
4.2 Name fallback when name is empty
When SeriesData.name is empty, Pie may try to use labels, but with an important prerequisite:
- If
ChartData.CoordinateSystem == None(typically pure Pie / no coordinate system), runtime skips label fallback and uses onlySeriesData.name.
When coordinate system is not None, the fallback order is:
- Prefer Category axis labels that match
Data.Cartesian.xAxisId - Otherwise, use labels from any Category axis
- Final fallback:
Slice {index}
Therefore: if you do not want to depend on axis configuration, fill
SeriesData.namedirectly.
4.3 Color source
- If
useColor=trueon the point: useSeriesData.color - Otherwise: use the built-in palette in order
5. Common settings (PieSettings)
Pie settings is PieSettings, mainly including:
layout: layout (angle/radius/gaps/center offset, etc.)hover: hover interaction (explode)aggregation: aggregation (TopN + Others)legend: Pie-specific legend settings (replaces global legend only for “pure Pie chart” cases)
4.1 layout (PieLayoutSettings)
Common fields:
startAngleDeg: start angle (default -90 makes the first slice start at the top)clockwise: clockwise/counter-clockwiseangleRangeDeg: angle range (default 360; use 180 for half-pie, etc.)outerRadius: outer radius<= 0: auto0~1: normalized by control size> 1: pixels
innerRadius: inner radius (Pie usually 0; >0 creates a hole, but RingChart is recommended for ring/progress style)innerRadiusColor: inner fill colorsliceGapPx: gap between slices (pixels)sliceGapType: gap mode (Radial/Translate/Uniform)cornerRadius: corner radius (pixels, limited by slice thickness)plot.padding: padding (avoid clipping slices/outside labels)plot.centerOffset: center offset
4.2 hover (PieHoverSettings)
hover.enabled: enable hover interactionhover.explodeType:Translate: translate the whole slicePull: pull out / stretchColor: brightenStroke: stroke emphasis
hover.explodeDistance: translate/pull distance (pixels)
4.3 aggregation (PieAggregationSettings)
When there are many categories, you can merge small items into Others:
aggregation.enabled = truekeepTopN: keep top N, merge the restsortByValue: sort byvaluebefore taking TopNothersName: name for OthersuseOthersColor + othersColor: Others color
Note: aggregation only takes effect when
keepTopN > 0and slice count exceeds N.
6. Legend (PieLegendSettings) and “hide slice” interaction
When the chart is a “pure Pie chart” (only Pie/RingChart/Pie3D and no other types):
- Legend prefers
PieSettings.legend(or the legend on RingChartSettings/Pie3DSettings), instead ofChartData.legend. - Clicking a legend item toggles
HiddenPieSliceIds:- normal slices:
SeriesData.id(if empty, uses index string) - aggregated Others: always
__ec_pie_others__
- normal slices:
PieLegendSettings.source affects where legend items come from:
Slice: one entry per slice (default)RingSlice: provides label source for RingChart/RingSlice scenarios (prefers PolarAxes.angleAxis.labels)Series: one entry per serie (not slice-level)
7. Labels (SerieLabelSettings)
Pie labels are controlled by Serie.labelSettings:
show: whether to showfontSize / color / decimalPlaces: font and value formatshowName: whether to include slice nameposition:Outside/Inside/Centeroffset: offset
8. Common pitfalls (by symptoms)
-
Some slices are not visible
- Check whether the point
valueis<= 0
- Check whether the point
-
Slice name is not what I expect
- Recommended: fill
SeriesData.namedirectly - If you rely on labels: ensure you have a Category axis with
labels, and the order matches data point indices
- Recommended: fill
-
Slice colors change each time / hard to control
- For slices that need fixed colors: set
useColor=true+coloron the point
- For slices that need fixed colors: set
-
Hidden/interaction state is unstable
- Ensure each point
SeriesData.idis stable (do not regenerate ids on each refresh)
- Ensure each point
9. Next
- Ring chart (RingChart):
03_07-RingChart.md