Back to Devexpress

Series3DBase.Legend Property

wpf-devexpress-dot-xpf-dot-charts-dot-series3dbase-8a1dcd36.md

latest6.7 KB
Original Source

Series3DBase.Legend Property

Gets or sets a legend displaying the legend item of the series.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public Legend Legend { get; set; }
vb
Public Property Legend As Legend

Property Value

TypeDescription
Legend

The legend displaying the series item.

|

Example

This example illustrates how to assign legends to a Series3D:

Important

The series can use only legends that the Chart3DControl stores in the legend collection. Do not assign new legends to series properties.

xaml
<dxc:Chart3DControl>
    <dxc:Chart3DControl.DataContext>
        <local:SalesChartViewModel/>
    </dxc:Chart3DControl.DataContext>
    <dxc:Chart3DControl.XAxis>
        <dxc:XAxis3D>
            <dxc:XAxis3D.NumericScaleOptions>
                <dxc:ManualNumericScaleOptions/>
            </dxc:XAxis3D.NumericScaleOptions>
        </dxc:XAxis3D>
    </dxc:Chart3DControl.XAxis>
    <dxc:Chart3DControl.Legends>
        <dxc:Legend x:Name="legend"
                    HorizontalPosition="RightOutside"
                    VerticalPosition="Top">
            <dxc:Legend.Title>
                <dxc:LegendTitle Content="DevAV Sales"/>
            </dxc:Legend.Title>
        </dxc:Legend>
    </dxc:Chart3DControl.Legends>
    <dxc:Chart3DControl.SeriesSource>
        <dxc:Series3DStorage>
            <dxc:Series3D DisplayName="Manhattan Bars"
                          Legend="{Binding ElementName=legend}">
                <dxc:Series3D.PointSource>
                            <dxc:SeriesPoint3DDataSourceAdapter DataSource="{Binding SaleData}" 
                                                                XArgumentDataMember="Year"
                                                                YArgumentDataMember="Region" 
                                                                ValueDataMember="Value"/>
                        </dxc:Series3D.PointSource>
                <dxc:Series3D.View>
                    <dxc:Bar3DSeriesView>
                        <dxc:Bar3DSeriesView.Colorizer>
                            <dxc:KeyColorColorizer3D>
                                <dxc:KeyColorColorizer3D.KeyProvider>
                                    <dxc:XArgumentKeyProvider3D/>
                                </dxc:KeyColorColorizer3D.KeyProvider>
                            </dxc:KeyColorColorizer3D>
                        </dxc:Bar3DSeriesView.Colorizer>
                    </dxc:Bar3DSeriesView>
                </dxc:Series3D.View>
            </dxc:Series3D>
        </dxc:Series3DStorage>
    </dxc:Chart3DControl.SeriesSource>
</dxc:Chart3DControl>
csharp
public class SaleInfo {
    public int Year { get; }
    public string Region { get; }
    public decimal Value { get; }

    public SaleInfo(int year, string region, decimal value) {
        this.Year = year;
        this.Region = region;
        this.Value = value;
    }
}

class SalesChartViewModel {
    public IReadOnlyList<SaleInfo> SaleData { get; }

    public SalesChartViewModel() {
        int lastYear = DateTime.Now.Year - 1;

        SaleData = new List<SaleInfo> {
            new SaleInfo(lastYear - 2, "Asia", 4.23M),
            new SaleInfo(lastYear - 2, "North America", 3.485M),
            new SaleInfo(lastYear - 2, "Europe", 3.088M),
            new SaleInfo(lastYear - 2, "Australia", 1.78M),
            new SaleInfo(lastYear - 2, "South America", 1.602M),
            new SaleInfo(lastYear - 1, "Asia", 4.768M),
            new SaleInfo(lastYear - 1, "North America", 3.747M),
            new SaleInfo(lastYear - 1, "Europe", 3.357M),
            new SaleInfo(lastYear - 1, "Australia", 1.957M),
            new SaleInfo(lastYear - 1, "South America", 1.823M),
            new SaleInfo(lastYear, "Asia", 5.289M),
            new SaleInfo(lastYear, "North America", 4.182M),
            new SaleInfo(lastYear, "Europe", 3.725M),
            new SaleInfo(lastYear, "Australia", 2.272M),
            new SaleInfo(lastYear, "South America", 2.117M)
        };
    }
}
vb
Public Class SaleInfo
    Public ReadOnly Property Year As Integer
    Public ReadOnly Property Region As String
    Public ReadOnly Property Value As Decimal

    Public Sub New(ByVal year As Integer, ByVal region As String, ByVal value As Decimal)
        Me.Year = year
        Me.Region = region
        Me.Value = value
    End Sub
End Class

Class SalesChartViewModel
    Public ReadOnly Property SaleData As IReadOnlyList(Of SaleInfo)

    Public Sub New()
        Dim lastYear = DateTime.Now.Year - 1

        SaleData = New List(Of SaleInfo) From {
            New SaleInfo(lastYear - 2, "Asia", 4.23D),
            New SaleInfo(lastYear - 2, "North America", 3.485D),
            New SaleInfo(lastYear - 2, "Europe", 3.088D),
            New SaleInfo(lastYear - 2, "Australia", 1.78D),
            New SaleInfo(lastYear - 2, "South America", 1.602D),
            New SaleInfo(lastYear - 1, "Asia", 4.768D),
            New SaleInfo(lastYear - 1, "North America", 3.747D),
            New SaleInfo(lastYear - 1, "Europe", 3.357D),
            New SaleInfo(lastYear - 1, "Australia", 1.957D),
            New SaleInfo(lastYear - 1, "South America", 1.823D),
            New SaleInfo(lastYear, "Asia", 5.289D),
            New SaleInfo(lastYear, "North America", 4.182D),
            New SaleInfo(lastYear, "Europe", 3.725D),
            New SaleInfo(lastYear, "Australia", 2.272D),
            New SaleInfo(lastYear, "South America", 2.117D)
        }
    End Sub
End Class

The following properties allow you to configure chart elements to series binding:

SymbolDescription
Series3DBase.LegendGets or sets a legend displaying the legend item of the series.
LegendRepresents a chart control’s legend.
ChartControlBase.LegendsReturns the collection of chart legends.

See Also

Series3DBase Class

Series3DBase Members

DevExpress.Xpf.Charts Namespace