# Getting Started with the .NET MAUI PieChart

This guide provides the information you need to start using the Telerik UI for [.NET MAUI PieChart](https://www.telerik.com/maui-ui/documentation/controls/charts/pie-chart/overview) by adding the control to your project.

At the end, you will be able to achieve the following result.

![Telerik UI for .NET MAUI PieChart default view showing a four-slice pie chart](https://www.telerik.com/maui-ui/documentation/assets/c931ac7f2ab83feef55171f20c1ecb95/charts-pie-getting-started.png)

## Prerequisites

Before adding the Pie Chart, you need to:

1. [Set up your .NET MAUI application](https://www.telerik.com/maui-ui/documentation/get-started/quickstart#prerequisites).

2. [Set Up Telerik Development Environment](https://www.telerik.com/maui-ui/documentation/get-started/quickstart#set-up-telerik-development-environment)

## Define the Control

1. When your .NET MAUI application is set up, you are ready to add a `RadPieChart` to your page. The following example defines a chart with a `PieSeries`:

   ```XAML
   <charts:RadPieChart>
       <charts:RadPieChart.BindingContext>
           <models:PieViewModel />
       </charts:RadPieChart.BindingContext>
       <charts:RadPieChart.Series>
           <charts:PieSeries ValueBinding="Value"
                             LabelBinding="Label"
                             ItemsSource="{Binding Data}" />
       </charts:RadPieChart.Series>
   </charts:RadPieChart>
   ```

2. Add the `charts` namespace:

   ```XAML
   xmlns:charts="clr-namespace:Telerik.Maui.Controls.Charts;assembly=Telerik.Maui.Controls"
   ```

3. Add sample data to the `PieSeries`:

   ```C#
   public class PieData
   {
       public string Label { get; set; }

       public double Value { get; set; }
   }
   ```

4. Define the `ViewModel`:

   ```C#
   public class PieViewModel
   {
       public ObservableCollection<PieData> Data { get; } = new ObservableCollection<PieData>
       {
           new PieData { Label = "Mobile", Value = 45 },
           new PieData { Label = "Desktop", Value = 30 },
           new PieData { Label = "Tablet", Value = 15 },
           new PieData { Label = "Other", Value = 10 },
       };
   }
   ```

5. Register the Telerik controls through the `Telerik.Maui.Controls.Compatibility.UseTelerik` extension method called inside the `CreateMauiApp` method of the `MauiProgram.cs` file of your project:

   ```C#
   using Telerik.Maui.Controls.Compatibility;

   public static class MauiProgram
   {
       public static MauiApp CreateMauiApp()
       {
           var builder = MauiApp.CreateBuilder();
           builder
               .UseTelerik()
               .UseMauiApp<App>()
               .ConfigureFonts(fonts =>
               {
                   fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
               });
           return builder.Build();
       }
   }
   ```

The `PieSeries` binds to a collection of items through its `ItemsSource` property, while the `ValueBinding` and `LabelBinding` properties define which data-item members supply the value and the label of each slice.

> For a runnable example with the Pie Chart Getting Started scenario, go to the [SDKBrowser Demo Application](https://www.telerik.com/maui-ui/documentation/demos-and-sample-apps/sdkbrowser-app) and navigate to the **Charts > Getting Started** category.

## Additional Resources

* [.NET MAUI Pie Chart Series](https://www.telerik.com/maui-ui/documentation/controls/charts/pie-chart/series/pie-series)
* [.NET MAUI Charts Product Page](https://www.telerik.com/maui-ui/charts)
* [.NET MAUI Charts Forum Page](https://www.telerik.com/forums/maui)

## See Also

* [Pie Chart Series](https://www.telerik.com/maui-ui/documentation/controls/charts/pie-chart/series/pie-series)
* [Pie Chart Visual Structure](https://www.telerik.com/maui-ui/documentation/controls/charts/pie-chart/visual-structure)
