Version

Configuring Basic Legend

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.

Overview

The topic is organized as follows:

Introduction

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.

Properties

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.

Property Name Property Type Description

Orientation

Determines vertical/horizontal orientation of legend items in the legend.

DataTemplate

Determines a template for the legend item of a given chart series.

Requirements

The Legend control supports any type of Chart Series and it will display legend item for each series in the chart plot area.

Code Example

This code snippet demonstrates how to share Legend between two BubbleSeries objects as shown on Figure 1.

xamDataChart Legends 02.png

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)