# Data Binding with Automatic Series Mappings

One of the features of the **RadChart** is the automatic series mapping. With automatic series mapping, you can easily create a chart by simply setting the **RadChart.ItemsSource** to the data source you have. **RadChart** will create a chart series for every numeric field in the data source by mapping the numeric value to the **DataPointMember.YValue** field for each respective series. The type of the chart depends on the **RadChart.DefaultSeriesDefinition** property and by default it is set to **BarSeriesDefinition**.

> Note that SeriesDefinition set through the **RadChart.DefaultSeriesDefinition** property does not support change notifications i.e. if you try to change a **RadChart.DefaultSeriesDefinition** property after the control is databound, it will not have any effect till the next rebind operation. The recommended approach in this scenario would be to use unique **SeriesMapping.SeriesDefinition** or alternatively you can access the generated DataSeries directly (i.e. RadChart.DefaultView\.ChartArea.DataSeries\[i]) and update its **DataSeries.Definition** properties.

The purpose of this tutorial is to show you how to use **RadChart** with **Automatic Series Mappings**.

> The automatic mapping mode will not work for chart series that require multiple data fields for its correct operation (e.g. the **CandleStick** type).

## Binding to an Array of Integers

Take a look at this simple array declaration:

```C#
	int[] dataArray = new int[] { 12, 56, 23, 89, 12, 56, 34, 78, 32, 56 };
```

```VB.NET
	Dim dataArray As Integer() = New Integer() {12, 56, 23, 89, 12, 56, 34, 78, 32, 56}
```

If you set it to the **ItemsSource** property of the **RadChart** control, you will have the following result:

![WPF RadChart  ](https://www.telerik.com/products/wpf/documentation/assets/84ff6d67dcf7c1ab2240f6ac7f1b2d34/radchart_populatingwithdata_automaticseriesmapping_01.png)

```C#
	radChart.ItemsSource = dataArray;
```

```VB.NET
	radChart.ItemsSource = dataArray
```

## Binding to a List of Business Objects

If you have a list of business objects and you set it to the **ItemsSource** property of the **RadChart** control, the result will be one chart series per numeric property:

```C#
	List<Manufacturer> data = new List<Manufacturer>();
	data.Add(new Manufacturer("Toyota", 215, 462));
	data.Add(new Manufacturer("General Motors", 192, 345));
	data.Add(new Manufacturer("Volkswagen", 151, 310));
	data.Add(new Manufacturer("Ford", 125, 340));
	data.Add(new Manufacturer("Honda", 91, 201));
	data.Add(new Manufacturer("Nissan", 79, 145));
	data.Add(new Manufacturer("PSA", 79, 175));
	data.Add(new Manufacturer("Hyundai", 64, 133));
	
	this.telerkChart.ItemsSource = data;
```

```VB.NET
	Dim data As New List(Of Manufacturer)()
	data.Add(New Manufacturer("Toyota", 215, 462))
	data.Add(New Manufacturer("General Motors", 192, 345))
	data.Add(New Manufacturer("Volkswagen", 151, 310))
	data.Add(New Manufacturer("Ford", 125, 340))
	data.Add(New Manufacturer("Honda", 91, 201))
	data.Add(New Manufacturer("Nissan", 79, 145))
	data.Add(New Manufacturer("PSA", 79, 175))
	data.Add(New Manufacturer("Hyundai", 64, 133))
	
	Me.telerkChart.ItemsSource = data
```

Where the structure of the **Manufacturer** class is:

```C#
	public class Manufacturer
	{
	    public Manufacturer( string name, int sales, int turnover )
	    {
	        this.Name = name;
	        this.Sales = sales;
	        this.Turnover = turnover;
	    }
	    public string Name
	    {
	        get;
	        set;
	    }
	    public int Sales
	    {
	        get;
	        set;
	    }
	    public int Turnover
	    {
	        get;
	        set;
	    }
	}
```

```VB.NET
	Public Class Manufacturer
	    Public Sub New(ByVal name As String, ByVal sales As Integer, ByVal turnover As Integer)
	        Me.Name = name
	        Me.Sales = sales
	        Me.Turnover = turnover
	    End Sub
	
	    Private _Name As String
	    Public Property Name() As String
	        Get
	            Return _Name
	        End Get
	        Set(ByVal value As String)
	            _Name = value
	        End Set
	    End Property
	
	    Private _Sales As Integer
	    Public Property Sales() As Integer
	        Get
	            Return _Sales
	        End Get
	        Set(ByVal value As Integer)
	            _Sales = value
	        End Set
	    End Property
	
	    Private _Turnover As Integer
	    Public Property Turnover() As Integer
	        Get
	            Return _Turnover
	        End Get
	        Set(ByVal value As Integer)
	            _Turnover = value
	        End Set
	    End Property
	End Class
```

The result is shown on the next figure.

![WPF RadChart  ](https://www.telerik.com/products/wpf/documentation/assets/cf6fc05997222ad67daf4b62de22a947/radchart_populatingwithdata_automaticseriesmapping_02.png)

As you can see, automatic series mapping can be useful for simple data. However, if you need more data binding options, take a look at the [Data Binding with Manual Series Mapping](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/data-binding-with-manual-series-mapping) topic and the [Data Binding to Nested Collections](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/data-binding-to-nested-collections) topic.

## See Also

* [Populating with Data Overview](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/overview)

* [Data Binding Support Overview](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/data-binding-support-overview)

* [Data Binding with Manual Series Mapping](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/data-binding-with-manual-series-mapping)

* [Data Binding to Nested Collections](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/data-binding-to-nested-collections)

* [Data Binding to Many Chart Areas](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/data-binding-to-many-chart-areas)

* [Creating a Chart Declaratively](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/creating-chart-declaratively)

* [Creating a Chart in Code-behind](https://www.telerik.com/products/wpf/documentation/controls/radchart/populating-with-data/creating-chart-in-code-behind)
