Version

Configuring Item Legend

This topic provides information on how to configure ItemLegend 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 Item Legend control identifies data items bound to BubbleSeries with their visual representation in the chart plot area. Legend’s visuals consist of a list of legend items that have legend badge representing a color of series as well as legend text that matches LabelMemberPath property of data item. Also, the ItemLegend has a legend title that is displayed above legend items.

Properties

The Item 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.

Requirements

The ItemLegend control supports only BubbleSeries and it displays legend item for each data member bound to the series. The following table lists all requirements for this legend.

Series Property Property Type Description

{LegendBaseName}

Determines which Item Legend to bind to the series

string

Data column determining labels for bubbles

DataTemplate

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

Code Example

This code snippet demonstrates how to bind ItemLegend to BubbleSeries with LabelMemberPath mapped to a Label data column. (Figure 3)

xamDataChart Legends 04.png

Figure 1: Item Legend bound to BubbleSeries with LabelMemberPath mapped to a Label data column

In XAML:

<ig:XamDataChart >
    <ig:XamDataChart.Series>
        <ig:BubbleSeries Legend="{Binding ElementName=ItemLegend}"
                         LabelMemberPath="Label">
        </ig:BubbleSeries>
    </ig:XamDataChart.Series>
</ig:XamDataChart>
<ig:ItemLegend x:Name="ItemLegend" Content="Item Legend" />

In C#:

var itemLegend = new ItemLegend
{
    Content = "Item Legend"
};
var series = new BubbleSeries();
series.LabelMemberPath = "Label";
series.Legend = itemLegend;
var DataChart = new XamDataChart();
dataChart.Series.Add(series);

In Visual Basic:

Dim itemLegend As New ItemLegend() With { .Content = "Item Legend" }
Dim series As New BubbleSeries()
series.LabelMemberPath = "Label"
series.Legend = itemLegend
Dim dataChart As New XamDataChart()
dataChart.Series.Add(series)