Xceed Toolkit Plus for WPF v5.1 Documentation
Xceed.Wpf.Toolkit Assembly / Xceed.Wpf.Toolkit.Chart Namespace / Chart Class / Legend Property
Example


In This Topic
    Legend Property
    In This Topic
    Gets or sets chart Legend.
    Syntax
    'Declaration
     
    
    Public Property Legend As Legend
    'Usage
     
    
    Dim instance As Chart
    Dim value As Legend
     
    instance.Legend = value
     
    value = instance.Legend
    public Legend Legend {get; set;}

    Property Value

    The chart's legend.
    Example
    The following example shows how to set up a legend that displays information related to two Series, each of which is contained in a different Area in the chart. The legend's Dock, AllowResize, AllowDock, AllowMove, and Title propeties are used to specify its appearance and behavior.
    <Window x:Class="WpfApplication56.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <DataTemplate x:Key="ColumnTemplate">
                <Canvas Width="{Binding Path=W}" Height="{Binding Path=H}">
                    <Rectangle RadiusX="25" RadiusY="25" Width="{Binding Path=W}" Height="{Binding Path=H}" Fill="{Binding Path=Interior}" />
                </Canvas>
            </DataTemplate>
        </Window.Resources>
        
        <Grid>
            <xctk:Chart >
                <xctk:Chart.Legend>
                    <xctk:Legend x:Name="_legend"
                                      Dock="Left"
                                      AllowResize="True"
                                      AllowDock="True"
                                      AllowMove="True"
                                      Title="Legend"/>
                </xctk:Chart.Legend>
                <xctk:Chart.Areas>
                    <xctk:Area Title="Wins/month">
                        <xctk:Area.XAxis>
                            <xctk:Axis ShowAxisLabel="False" ShowTickLabels="False" ShowTicks="False"/>
                        </xctk:Area.XAxis>
                        <xctk:Area.YAxis>
                            <xctk:Axis  ShowAxisLabel="False" ShowTickLabels="False" ShowTicks="False"/>
                        </xctk:Area.YAxis>
                        <xctk:Area.Series>
                            <xctk:Series  Title="Months"
                                              DefaultInterior="Green"
                                              ShowPointsInLegend="True"
                                              ShowHintLabels="True">
                                <xctk:Series.Layout>
                                    <xctk:PieLayout />
                                </xctk:Series.Layout>
                                <xctk:Series.DataPoints>
                                    <xctk:DataPoint X="6" Y="6" Label="Jan" />
                                    <xctk:DataPoint X="7" Y="7" Label="Feb"/>
                                    <xctk:DataPoint X="4" Y="4" Label="Mar" />
                                    <xctk:DataPoint X="2" Y="2" Label="Apr"/>
                                </xctk:Series.DataPoints>
                            </xctk:Series>
                        </xctk:Area.Series>
                    </xctk:Area>
    
                    <xctk:Area Title="Goals/player">
                        <xctk:Area.XAxis>
                            <xctk:Axis Title="Player's Name" LabelsType="Labels" GraduationMode="Manual"/>
                        </xctk:Area.XAxis>
                        <xctk:Area.YAxis>
                            <xctk:Axis Title="Goals" AxisLabelsLayout="ShowToFit"/>
                        </xctk:Area.YAxis>
                        <xctk:Area.Series>
                            <xctk:Series  Title="Players"
                                              DefaultInterior="Orange">
                                <xctk:Series.Layout>
                                    <xctk:ColumnLayout />
                                </xctk:Series.Layout>
                                <xctk:Series.DataPoints>
                                    <xctk:DataPoint Y="36" Label="Tom" />
                                    <xctk:DataPoint Y="7" Label="Steven"/>
                                    <xctk:DataPoint Y="24" Label="Kirk" />
                                    <xctk:DataPoint Y="12" Label="Erik"/>
                                    <xctk:DataPoint Y="10" Label="Scott"/>
                                </xctk:Series.DataPoints>
                            </xctk:Series>
                        </xctk:Area.Series>
                    </xctk:Area>
                </xctk:Chart.Areas>
            </xctk:Chart>
        </Grid>
    </Window>
    Supported Frameworks

    .NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.

    .NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.

    See Also