Chart / Charts / Chart Types / Pie / Pie Series
In This Topic
    Pie Series
    In This Topic

    You add data to a pie chart by adding one or more pie series to its Series collection. When the Series collection contains more than one series the pie chart becomes a doughnut chart. The following pictures show a typical pie and doughnut charts:

     Creating a Pie Series

    Pie series are represented by the NPieSeries type. An instance of this type must be added to the series collection of a Pie chart:

    C#
    Copy Code
    NPieSeries pieSeries = new NPieSeries();
    pieChart.Series.Add(pieSeries); 
    
     Passing Data

    Pie series accepts data points of type NPieDataPoint. The following code snippet shows how to add data to a pie series:

    C#
    Copy Code
    NPieDataPoint pieDataPoint = new NPieDataPoint();
    pieDataPoint.Value = 10;
    pieSeries.DataPoints.Add(pieDataPoint);
    
     Controlling the pie shape

    The shape of the pie segments can be controlled through the PieSegmentShape property. It accepts values from the ENPieSegment enumeration. For example, the following code will display a smooth edge pie chart:

    C#
    Copy Code
    pieSeries.PieSegmentShape = ENPieSegmentShape.SmoothEdgePie;
    

    The following table lists the different pie segment shapes:

    Pie Smooth Edge Pie Cut Edge Pie
    Ring Smooth Edge Ring Cut Edge Ring
    Torus
     Data Labels Layout

    The LabelMode property of the NPieSeries object controls how pie labels a positioned and laid out. The following table lists the available options:

    ENPieLabelMode Description
    Center

    Pie labels are displayed in the center of the pie segment:

    Rim

    Pie labels are displayed on the rim of the pie segment:

    Spider

    Pie labels are displayed on equal X coordinate distance from the center of the pie on the left and right side depending on the pie segment middle angle:

     The following code snippet shows how to change the label mode of a pie series:

    C#
    Copy Code
    pieSeries.LabelMode = ENPieLabelMode.Spider;
    
    Depending on the LabelMode different label layouts apply. In case the LabelMode is set to ENPieLabelMode.Center or ENPieLabelMode.Rim pie labels are treated as normal data labels and the options described in the Series Label Layout apply. In case the LabelMode is set to ENPieLabelMode.Spider you can control the spider arrow length from the SpiderArrowLength property of the pie series.
     Formatting Commands

    The pie series supports the following formatting commands in addition to the standard (per data point) formatting commands:

    <total> - displays the absolute sum of the values in the pie series.
    <cumulative> - displays the sum of the values up to the current pie data point.
    <percent> - displays the percent contribution of the pie value to the total pie sum.

     

    See Also