Back to Devexpress

PieSeriesDataAdapter.LabelDataMember Property

maui-devexpress-dot-maui-dot-charts-dot-pieseriesdataadapter-7c5273bc.md

latest3.1 KB
Original Source

PieSeriesDataAdapter.LabelDataMember Property

Gets or sets the data source member that provides the data for the chart labels. This is a bindable property.

Namespace : DevExpress.Maui.Charts

Assembly : DevExpress.Maui.Charts.dll

NuGet Package : DevExpress.Maui.Charts

Declaration

csharp
public string LabelDataMember { get; set; }

Property Value

TypeDescription
String

Stores the property name of the chart label.

|

Example

This example shows how to provide data for the PieSeries.

Note

If you want to provide data for the ChartView, use the SeriesDataAdapter class.

Set the PieSeries.Data property to a new PieSeriesDataAdapter instance. Use the DataSource, ValueDataMember, and LabelDataMember properties to specify the data source for the chart, and to define data source members used to generate series points and labels.

csharp
using System.Collections.Generic;
using Microsoft.Maui.Graphics;
// ...

class ViewModel {
    public IReadOnlyList<LandAreaItem> LandAreas { get; }

    public ViewModel() {
        LandAreas = new List<LandAreaItem>() {
            new LandAreaItem("Russia", 17.098),
            new LandAreaItem("Canada", 9.985),
            new LandAreaItem("People's Republic of China", 9.597),
            new LandAreaItem("United States of America", 9.834),
            new LandAreaItem("Brazil", 8.516),
            new LandAreaItem("Australia", 7.692),
            new LandAreaItem("India", 3.287),
            new LandAreaItem("Others", 81.2)
        };
    }
}

class LandAreaItem {
    public string CountryName { get; }
    public double Area { get; }

    public LandAreaItem(string countryName, double area) {
        this.CountryName = countryName;
        this.Area = area;
    }
}
xaml
<dxc:PieChartView>
    <dxc:PieChartView.BindingContext>
        <local:ViewModel/>
    </dxc:PieChartView.BindingContext>
    <dxc:PieChartView.Series>
        <dxc:PieSeries>
            <dxc:PieSeries.Data>
                <dxc:PieSeriesDataAdapter DataSource="{Binding LandAreas}" 
                                          LabelDataMember="CountryName" 
                                          ValueDataMember="Area"/>
            </dxc:PieSeries.Data>
        </dxc:PieSeries>
    </dxc:PieChartView.Series>
</dxc:PieChartView>

See Also

PieSeriesDataAdapter Class

PieSeriesDataAdapter Members

DevExpress.Maui.Charts Namespace