UI Elements
Pie Chart A dynamic pie and donut chart
Pie Chart renders a circular graph divided into colored slices based on numeric values. It supports donut mode (inner radius), percentage or value labels, background labels, and a fully dynamic legend.
The chart is generated from scratch each time the data or layout changes. All slices, labels, backgrounds, borders, and legend items are built at runtime and updated when the RectTransform size changes.
Name Type Description dataPointsList<DataPoint>Label, value, and color entries
DataPoint
Field Type Description labelstringCategory label valuefloatValue used to calculate slice percentage colorColorColor for slice rendering tableKey (optional)stringLocalization key
Name Type Description innerRadiusfloatTurns chart into donut shape when greater than zero startAnglefloatStarting angle for first slice segmentsintResolution used to build slices enableAntiAliasingboolEnables edge smoothing antiAliasingWidthfloatWidth of AA gradient
Name Type Description drawBorderboolDraws outer (and inner if donut) border borderWidthfloatThickness of border rings
Name Type Description showLabelsboolDisplays labels inside slices showPercentagesboolShows percentage instead of value labelFontSizefloatFont size for labels drawLabelBackgroundboolDraws a background behind label labelBackgroundSpriteSpriteSprite for label background labelBackgroundPPUfloatPPU multiplier for background labelPaddingVector2Padding around label text
Name Type Description showLegendboolToggles legend legendContainerRectTransformParent for generated legend items legendItemHeightfloatHeight for each legend row legendColorBoxSizefloatSize of color square legendColorBoxSpriteSpriteOptional sprite for color boxes legendFontSizefloatFont size of legend text
Name Type Description stylingSourceStylingSourceCustom or StylerPreset stylerPresetStylerPresetUsed for Styler based styling borderColorColorMappingColor for chart border labelColorColorMappingColor for label text labelBackgroundColorColorMappingColor for label background legendTextColorColorMappingColor for legend text labelFontFontMappingFont for label text legendFontFontMappingFont for legend entries
Name Parameters Description DrawChart()None Rebuilds the entire chart UpdateData(newData)List<DataPoint>Replaces all data and redraws AddDataPoint(label, value, color)string, float, ColorAdds new slice RemoveDataPoint(index)intRemoves slice ClearData()None Clears all slices SetDataPoint(index, label, value, color?)int, string, float, Color?Updates a specific slice SetDataPoint(data, label, value, color?)DataPoint, string, float, Color?Updates by reference SetInnerRadius(newRadius)floatUpdates donut radius and redraws ShowLabelsboolEnables or disables labels ShowLegendboolEnables or disables legend
using UnityEngine ;
using Evo . UI ;
public class PieChartExample : MonoBehaviour
{
public PieChart chart ;
void Start ()
{
// Modify data
chart. AddDataPoint ( "Apples" , 40 , new Color ( 1f , 0.3f , 0.3f ));
chart. AddDataPoint ( "Bananas" , 25 , new Color ( 1f , 0.9f , 0.2f ));
chart. SetDataPoint ( 1 , "Bananas" , 30 );
// Turn into a donut chart
chart. SetInnerRadius ( 60f );
// Toggle legend
chart.ShowLegend = true ;
// Redraw chart
chart. DrawChart ();
}
}