# Pie Charts

The Telerik UI Pie Chart HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI Pie Chart widget.

Pie Charts display data as single-series sectors from a two-dimensional circle which is useful for rendering data as a part of the whole.

* [Demo page for the Pie Chart HtmlHelper](https://demos.telerik.com/aspnet-mvc/pie-charts/index)

## Getting Started

The [Telerik UI Donut Chart component for ASP.NET MVC](https://demos.telerik.com/aspnet-mvc/donut-charts/index) is a Pie Chart variation with the same ability to display a single data series in a two-dimensional circle and is likewise useful for displaying data as a part of the whole.

To create a Pie series in the Chart component, use `Pie` in the `Series` configuration.

* [Creating the Pie Chart](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/charts/chart-types/pie-charts#creating-the-pie-chart)
* [Configuring the labels visibility](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/charts/chart-types/pie-charts#configuring-the-labels-visibility)
* [Configuring the labels alignment](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/charts/chart-types/pie-charts#configuring-the-labels-alignment)
* [Configuring the effects overlay](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/charts/chart-types/pie-charts#configuring-the-effects-overlay)

## Creating the Pie Chart

The following example demonstrates how to define a single series of type `"pie"`. Additional series are not supported and each data point is an object that specifies the point value, category label, and other properties.

```Razor HtmlHelper
    @(Html.Kendo().Chart()
        .Name("chart")
        .Title("Break-up of Spain Electricity Production for 2008")
        .Legend(legend => legend
            .Position(ChartLegendPosition.Bottom)
        )
        .SeriesColors(new string[] { "#03a9f4", "#ff9800", "#fad84a", "#4caf50" })
        .Series(series =>
        {
            series.Pie(new dynamic[] {
            new {category="Hydro",value=22,color="#9de219"},
            new {category="Solar",value=2,color="#90cc38"},
            new {category="Nuclear",value=49,color="#068c35"},
            new {category="Wind",value=27,color="#006634"}})
            .Overlay(o => o.Gradient(ChartSeriesGradient.RoundedBevel));
        })
        .Tooltip(tooltip => tooltip.
            Template("${ category } - ${ value }%").Visible(true)
        )
    )
```

![UI for ASP.NET MVC A sample Pie Chart](https://www.telerik.com/aspnet-mvc/documentation/assets/a8233b81a9c2f6de2c48e375ff366483/pie-chart-roundedbevel.png)

## Configuring the Labels Visibility

The Telerik UI for ASP.NET MVC Pie Chart enables you to show or hide labels through the `Visible()` configuration method for the given series.

```Razor HtmlHelper
    .Series(series =>
    {
        series.Pie(new dynamic[] {})
    		.Labels(labels => labels
    			.Visible(true)
    		);
    })
```

## Configuring the Labels Alignment

The Telerik UI for ASP.NET MVC Pie Chart allows you to configure the label alignment for the series through the `Align()` configuration method.

```Razor HtmlHelper
    .Series(series =>
    {
        series.Pie(new dynamic[] {})
    		.Labels(labels => labels
    			.Align(ChartSeriesLabelsAlign.Circle)
    		);
    })
```

The Pie Chart support two modes of label alignment:

* `Circle`(default)—The labels are positioned in a circle around the Chart.

  ![UI for ASP.NET MVC A Pie Chart with circle aligned labels](https://www.telerik.com/aspnet-mvc/documentation/assets/f0f49b592e0b175103ffcf06615d15c2/pie-chart-labels-circle.png)
* `Column`—The labels are positioned in columns to the left and right of the Chart.

  ![UI for ASP.NET MVC A Pie Chart with column aligned labels](https://www.telerik.com/aspnet-mvc/documentation/assets/2ee6a53cd9097c422b23647c838126df/pie-chart-labels-column.png)

## Configuring the Effects Overlay

Each segment has a transparent effect overlay that adds depth to the two-dimensional shape. The overlay transparent gradient is configurable.

```Razor HtmlHelper
    .Series(series =>
    {
       series.Pie(new dynamic[] {})
       .Overlay(o => o.Gradient(ChartSeriesGradient.None));
    })
```

The Pie Chart supports the following `ChartSeriesGradient` options:

* (Default) `RoundedBevel`

  ![UI for ASP.NET MVC A Pie Chart with roundedBevel overlay](https://www.telerik.com/aspnet-mvc/documentation/assets/a8233b81a9c2f6de2c48e375ff366483/pie-chart-roundedbevel.png)

* `SharpBevel`

  ![UI for ASP.NET MVC A Pie Chart with sharpBevel overlay](https://www.telerik.com/aspnet-mvc/documentation/assets/39f9d291da77dd85194c1a38e0ade01e/chart-pie-overlay-sharpbevel.png)

* `None`

  ![UI for ASP.NET MVC A Pie Chart with no overlay](https://www.telerik.com/aspnet-mvc/documentation/assets/1929933f69116b3ffa3d9cef6c9e8864/chart-pie-overlay-none.png)

## See Also

* [Basic Usage of the Pie Chart HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/pie-charts/index)

* [Data Binding Options for the Telerik UI for ASP.NET MVC Charts](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/charts/data-binding)

* [Server-Side API](https://www.telerik.com/aspnet-mvc/documentation/api/chart)
