mobilecontrols-devexpress-dot-xamarinforms-dot-charts-531b00d0.md
Provides the data for the PieChartView series.
Namespace : DevExpress.XamarinForms.Charts
Assembly : DevExpress.XamarinForms.Charts.dll
NuGet Package : DevExpress.XamarinForms.Charts
public class PieSeriesDataAdapter :
DataSourceAdapterBase,
IPieSeriesData
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.
using System.Collections.Generic;
using Xamarin.Forms;
// ...
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;
}
}
<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>
Object DataSourceAdapterBase PieSeriesDataAdapter
See Also