There are no limits as to the count of legend you can add to the chart. They must be added to the Chart.Legends property. MindFusion.Gauges for Silverlight supports two types of legends.
ChartLegend takes its labels from the ChartSeries.Title property of the ChartSeriesCollection it refers to. Use ChartLegend.Series to set the ChartSeriesCollection. The brushes for the rectangles that are drawn before each label are taken automatically from ChartSeries.Fills. If a given ChartSeries has more than brushes in its Fills property, the first brush is taken.
Here is a sample code that creates a ChartLegend that is bound to the Series collection of the chart.
C#
![]() |
---|
ChartLegend legend = new ChartLegend(); |
VB.NET
![]() |
---|
Dim legend As New ChartLegend() |
SeriesLegend is designed to give details about data in a single ChartSeries. Its labels and brushes are custom-set with the SeriesLegend.LabelsSource and SeriesLegend.BrushesSource properties.
Here is a sample code that creates a SeriesLegend with two brushes and two labels:
C#
![]() |
---|
SeriesLegend legend1 = new SeriesLegend(); |
VB.NET
![]() |
---|
Dim legend1 As New SeriesLegend() |
The following properties are used to customize how the legend looks:
You can place the legend anywhere around the plot area where the chart is drawn. The docking of the legend is set with the Dock attached property of the LayoutPanel, which contains both the chart and the legend. The alignment of the legend depends on its position: if its docked to the bottom or the top of the plot area, the alignment is set with the HorizontalAlignment. If the legend is placed at the left or right side of the plot area, its alignment is set with VerticalAlignment.
Here is sample code that palces a legend to the right of the plot area and algns it in the middle:
C#
![]() |
---|
LayoutPanel.SetDock(legend, Dock.Right); |
VB.NET
![]() |
---|
LayoutPanel.SetDock(legend, Dock.Right) |
A diagram of the legend classes.