Skip to main content

DataSourceAdapterBase.DataSource Property

Gets or sets the data source for the chart.

Namespace: DevExpress.XamarinForms.Charts

Assembly: DevExpress.XamarinForms.Charts.dll

NuGet Package: DevExpress.XamarinForms.Charts

Declaration

public object DataSource { get; set; }

Property Value

Type Description
Object

The data source object.

Remarks

Data source adapters support data collections that implement the IBindingList or INotifyCollectionChanged interface, and allow you to bind charts to IList, IList<T>, and DataTable collections directly.

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.

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;
    }
}
See Also