Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Pie Chart

Siticone Pie Chart

The SiticonePieChart is a classic, circular statistical graphic divided into slices to illustrate numerical proportions. It is fully customizable with themes, animations, and interactive features like slice highlighting (exploding slices).

Data Binding

To render a pie chart, you must bind a data source containing at least a label (Category) and a value (Magnitude).

Property Type Description & Usage Example
DataSource object chart.DataSource = myDataTable; The source of the data. Accepts DataTable, List<T>, or IEnumerable.
LabelMember string chart.LabelMember = "CategoryName"; The name of the property or column containing the labels for each slice.
ValueMember string chart.ValueMember = "Amount"; The name of the property or column containing the numeric values that determine slice size.

Appearance & Theming

Customize the visual style of the chart, including colors, labels, and slice effects.

Property Type Description & Usage Example
Theme PieChartTheme chart.Theme = SiticonePieChart.Themes.Find(t => t.Name == "Ocean"); Applies a predefined color palette. Options include "Ocean", "Sunset", "Forest", "Dark", etc.
ShowPercentageOnSlice bool chart.ShowPercentageOnSlice = true; If true, displays the percentage value directly on top of each slice.

Behavior & Interaction

Control animations and user interaction effects.

Property Type Description & Usage Example
EnableAnimations bool chart.EnableAnimations = true; Toggles the radial "sweep" animation when the chart loads.
EnableHighlight bool chart.EnableHighlight = true; If enabled, slices will "explode" outward slightly when hovered over.
ExplodeOffset float chart.ExplodeOffset = 15f; The distance in pixels a slice moves outward during the highlight effect.
EnableTooltips bool chart.EnableTooltips = true; Shows a tooltip with the slice label, value, and percentage on hover.

Public Methods

DataBind()
// Forces the chart to process the DataSource and render the slices.
// Must be called after changing the DataSource or mapping properties.
pieChart.DataBind();
GenerateSampleData()
// Populates the chart with dummy data for testing purposes.
pieChart.GenerateSampleData();

Events

Handle user interactions with specific slices.

Event Descriptions & Wiring
// 1. SliceClick Event
// Fires when a user clicks on a slice.
chart.SliceClick += (s, e) => 
{
                MessageBox.Show($"Selected: {e.Label} ({e.Percentage:F1}%)");
};

// 2. SliceHover Event
// Fires when the mouse pointer enters a slice.
chart.SliceHover += (s, e) => 
{
    statusLabel.Text = $"Hovering: {e.Label}";
};

Detailed Usage Examples

Example 1: Binding to a DataTable

Visualizing sales distribution by category.

C# - DataTable Binding
private void LoadSalesDistribution()
{
                DataTable dt = new DataTable();
    dt.Columns.Add("Category", typeof(string));
    dt.Columns.Add("Revenue", typeof(double));

    dt.Rows.Add("Electronics", 45000);
    dt.Rows.Add("Clothing", 28000);
    dt.Rows.Add("Home", 15000);
    dt.Rows.Add("Books", 8000);

    pieChart.DataSource = dt;
    pieChart.LabelMember = "Category";
    pieChart.ValueMember = "Revenue";
    
                // Apply styling
    pieChart.Theme = SiticonePieChart.Themes.FirstOrDefault(t => t.Name == "Ocean");
    pieChart.DataBind();
}

Example 2: Custom List Binding

Binding a list of custom objects for a browser usage chart.

C# - Object Binding
public class BrowserStat
{
                public string Name { get; set; }
                public double Usage { get; set; }
}

private void LoadBrowserStats()
{
                var stats = new List<BrowserStat>
    {
                new BrowserStat { Name = "Chrome", Usage = 65.2 },
                new BrowserStat { Name = "Safari", Usage = 18.5 },
                new BrowserStat { Name = "Edge", Usage = 5.3 },
                new BrowserStat { Name = "Firefox", Usage = 3.2 },
                new BrowserStat { Name = "Other", Usage = 7.8 }
    };

    pieChart.DataSource = stats;
    pieChart.LabelMember = "Name";
    pieChart.ValueMember = "Usage";
    
                // Style Customization
    pieChart.ShowPercentageOnSlice = true;
    pieChart.Theme = SiticonePieChart.Themes.FirstOrDefault(t => t.Name == "Dark Indigo");
    
    pieChart.DataBind();
}