![xamDataChart Legends 02.png](images/xamDataChart_Legends_02.png)
This topic provides information on how to configure Legend control and explains, with code examples, how to use it with Chart Series in the XamDataChart™ control.
The topic is organized as follows:
The basic Legend control identifies the title of a series with its visual representation of data in the chart plot area. Legend’s visuals consist of a list of legend items that have legend badge representing color of series as well as legend text that matches title of a series. Also, legend has a legend title that is displayed above legend items.
The basic Legend control shares common properties with other type of chart legends. Refer to the Chart Legends topic for a complete list of these common properties. The following table list all properties that are specific to the basic legend.
The Legend control supports any type of Chart Series and it will display legend item for each series in the chart plot area.
This code snippet demonstrates how to share Legend between two BubbleSeries objects as shown on Figure 1.
Figure 1: Basic Legend with two Bubble Series
In XAML:
<ig:XamDataChart >
...
<ig:XamDataChart.Series>
<ig:BubbleSeries Title="Bubble Series I"
Legend="{Binding ElementName=Legend1}">
</ig:BubbleSeries>
<ig:BubbleSeries Title="Bubble Series II"
Legend="{Binding ElementName=Legend1}" >
</ig:BubbleSeries>
</ig:XamDataChart.Series>
</ig:XamDataChart>
<ig:Legend x:Name="Legend1" Content="Legend" />
In C#:
using Infragistics.Controls.Charts;
using Infragistics;
...
var legend = new Legend();
legend.Content = "Legend"
var series1 = new BubbleSeries();
series1.Title = "Bubble Series I";
series1.Legend = legend;
var series2 = new BubbleSeries();
series2.Title = "Bubble Series II";
series2.Legend = legend;
var DataChart = new XamDataChart();
...
dataChart.Series.Add(series1);
dataChart.Series.Add(series2);
In Visual Basic:
Imports Infragistics.Controls.Charts
Imports Infragistics
...
Dim legend As New Legend()
legend.Content = "Legend"
Dim series1 As New BubbleSeries()
series1.Title = "Bubble Series I"
series1.Legend = legend
Dim series2 As New BubbleSeries()
series2.Title = "Bubble Series II"
series2.Legend = legend
Dim dataChart As New XamDataChart()
...
dataChart.Series.Add(series1)
dataChart.Series.Add(series2)