![xamDataChart Legends 03.png](images/xamDataChart_Legends_03.png)
This topic provides information on how to configure ScaleLegend control and explains, with code examples, how to use it with Chart Series in the XamDataChart™ control.
The topic is organized as follows:
The Scale Legend is a special type of legend that shows how the colors in the Brushes collection of the ValueBrushScale or CustomPaletteBrushScale are distributed among bubbles of the BubbleSeries. It also displays the lowest and the highest values from a data column that is mapped to the FillMemberPath property of BubbleSeries. For more information on how to use brush scales, please refer to the Scatter Bubble Series topic. Also, legend has a legend title that is displayed above legend items.
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.
The Scale Legend can be used with BubbleSeries only if the series meet the binding requirements listed in the following table.
This code snippet demonstrates how to bind Scale Legend to Bubble Series with ValueBrushScale as a fill scale of bubbles
Figure 2: A ScaleLegend bound to BubbleSeries with ValueBrushScale as a fill scale of bubbles
In XAML:
<ig:XamDataChart >
...
<ig:XamDataChart.Series>
<ig:BubbleSeries FillMemberPath="Radius"
Legend="{Binding ElementName=ScaleLegend}" >
<ig:BubbleSeries.FillScale>
<ig:ValueBrushScale MaximumValue="50" MinimumValue="5">
<ig:ValueBrushScale.Brushes>
<ig:BrushCollection>
<SolidColorBrush Color="#FFC6EEFB" />
<SolidColorBrush Color="#FF08C3FE" />
<SolidColorBrush Color="#FF08A5FE" />
<SolidColorBrush Color="#FF086AFE" />
<SolidColorBrush Color="#FF084CFE" />
</igCommon:BrushCollection>
</ig:ValueBrushScale.Brushes>
</ig:ValueBrushScale>
</ig:BubbleSeries.FillScale>
</ig:BubbleSeries>
</ig:XamDataChart.Series>
</ig:XamDataChart>
<ig:ScaleLegend x:Name="ScaleLegend" Content="Scale Legend"
Margin="20" Height="200" Width="120"
VerticalAlignment="Top" HorizontalAlignment="Right">
</ig:ScaleLegend >
In Visual Basic:
Imports Infragistics.Controls.Charts
Imports Infragistics
...
Dim scaleLegend As New ScaleLegend() With { _
.Content = "Scale Legend", _
.Margin = New Thickness(20), _
.VerticalAlignment = VerticalAlignment.Top, _
.HorizontalAlignment = HorizontalAlignment.Right _
}
Dim brushCollection As New BrushCollection()
brushCollection.Add(New SolidColorBrush(Color.FromArgb(&Hff, &HC6, &Hee, &Hfb)))
brushCollection.Add(New SolidColorBrush(Color.FromArgb(&Hff, &H08, &Hc3, &Hfe)))
brushCollection.Add(New SolidColorBrush(Color.FromArgb(&Hff, &H08, &Ha5, &Hfe)))
brushCollection.Add(New SolidColorBrush(Color.FromArgb(&Hff, &H08, &H6a, &Hfe)))
brushCollection.Add(New SolidColorBrush(Color.FromArgb(&Hff, &H08, &H4c, &Hfe)))
Dim brushScale As New ValueBrushScale()
brushScale.Brushes = brushCollection
brushScale.MinimumValue = 5
brushScale.MaximumValue = 200
Dim series As New BubbleSeries()
series.FillScale = brushScale
series.FillMemberPath = "Radius"
series.Legend = scaleLegend
...
Dim dataChart As New XamDataChart()
dataChart.Series.Add(series)
In C#:
using Infragistics.Controls.Charts;
using Infragistics;
var scaleLegend = new ScaleLegend
{
Content = "Scale Legend",
Margin = new Thickness(20),
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Right
};
var brushCollection = new BrushCollection();
brushCollection.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0xC6, 0xEE, 0xFB)));
brushCollection.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x08, 0xC3, 0xFE)));
brushCollection.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x08, 0xA5, 0xFE)));
brushCollection.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x08, 0x6A, 0xFE)));
brushCollection.Add(new SolidColorBrush(Color.FromArgb(0xFF, 0x08, 0x4C, 0xFE)));
var brushScale = new ValueBrushScale();
brushScale.Brushes = brushCollection;
brushScale.MinimumValue = 5;
brushScale.MaximumValue = 200;
var series = new BubbleSeries();
series.FillScale = brushScale;
series.FillMemberPath = "Radius";
series.Legend = scaleLegend;
...
var DataChart = new XamDataChart();
dataChart.Series.Add(series);