# Quick Start: Add data to FlexPie

## Content

This section describes how to add a FlexPie control to your iOS app and add data to it. This topic consists of three steps:

* [Step 1: Create a data source for FlexPie](/componentone/docs/xamarin/online-ios/controls/flexpieOverview/flexpieQuickStart#step-1-create-a-data-source-for-flexpie)
* [Step 2: Add a FlexPie control](/componentone/docs/xamarin/online-ios/controls/flexpieOverview/flexpieQuickStart#step-2-add-a-flexpie-control)
* [Step 3: Run the Application](/componentone/docs/xamarin/online-ios/controls/flexpieOverview/flexpieQuickStart#step-3-run-the-application)

The following image shows how the FlexPie appears, after completing the steps above:

![FlexPie](https://cdn.mescius.io/document-site-files/images/1398d806-ac3c-4763-a9b3-2c7a2f5b49fb/images/flexpiequickstart.png)

### Step 1: Create a data source for FlexPie

Add a new class to serve as the data source for FlexPie.

```csharp
public class PieChartData
      {
        public string Name {get; set;}
        public double Value {get; set;}
        public static IEnumerable<PieChartData> DemoData()
             {
                     List<PieChartData> result = new List<PieChartData> ();
                     string[] fruit = new string[]{"Oranges","Apples","Pears","Bananas","Pineapples" };
                     Random r = new Random ();
                     foreach (var f in fruit)
                     result.Add (new PieChartData { Name = f, Value = r.Next(100) * 101});
                     return result;
              }
          }
```

### Step 2: Add a FlexPie control

Complete the following steps to initialize a FlexPie control in C#.
**Add FlexPie control in StoryBoard**

1. In the **Solution Explorer**, click **Main.storyboard** to open the storyboard editor.
2. From the **Toolbox** under **Custom Components** tab, drag a FlexPie onto the **ViewController**.
<br>
    ![](https://cdn.mescius.io/document-site-files/images/1398d806-ac3c-4763-a9b3-2c7a2f5b49fb/images/pie-storyboard.png)

**Initialize FlexPie control in Code**
To initialize the FlexPie control, open the ViewController file from the Solution Explorer and replace its content with the code below. This overrides the **ViewDidLoad** method of the View controller in order to initialize FlexPie.

```csharp
public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            pieChart = new FlexPie();
            pieChart.Binding = "Value";
            pieChart.BindingName = "Name";
            pieChart.ItemsSource = PieChartData.DemoData();
            this.Add(pieChart);
        }
        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            pieChart.Frame = new CGRect (this.View.Frame.X, this.View.Frame.Y,
                                     this.View.Frame.Width, this.View.Frame.Height);            
        }
```

### Step 3: Run the Application

Press **F5** to run the application.