PointSeries.Data Property
Gets or sets the series data.
Namespace: DevExpress.XamarinForms.Charts
Assembly: DevExpress.XamarinForms.Charts.dll
NuGet Package: DevExpress.XamarinForms.Charts
Declaration
public IXYSeriesData Data { get; set; }
Property Value
Type | Description |
---|---|
IXYSeriesData | An object that provides data for the series. |
Remarks
To provide data for the point series, set the PointSeries.Data
property to the SeriesDataAdapter class instance. Use the adapter’s properties to specify the data source for the series, and to define the data source members used to generate series points and labels (this series type requires 1 argument and 1 value for a data point).
You can also create a custom data adapter to populate the series with data. For example, it can be useful when data is generated on the fly and you don’t need to store it.
<ContentPage.BindingContext>
<local:MainViewModel/>
</ContentPage.BindingContext>
<dxc:ChartView>
<dxc:ChartView.Series>
<dxc:PointSeries>
<dxc:PointSeries.Data>
<dxc:SeriesDataAdapter DataSource="{Binding NightTemperature}"
ArgumentDataMember="Month">
<dxc:ValueDataMember Type="Value" Member="Temperature"/>
</dxc:SeriesDataAdapter>
</dxc:PointSeries.Data>
</dxc:PointSeries>
</dxc:ChartView.Series>
</dxc:ChartView>
public class MainViewModel {
public List<WeatherDataItem> NightTemperature { get; }
public MainViewModel() {
NightTemperature = new List<WeatherDataItem> {
new WeatherDataItem(new DateTime(2001, 1, 1), 2),
new WeatherDataItem(new DateTime(2001, 2, 1), 2),
new WeatherDataItem(new DateTime(2001, 3, 1), 3),
new WeatherDataItem(new DateTime(2001, 4, 1), 5),
new WeatherDataItem(new DateTime(2001, 5, 1), 8),
new WeatherDataItem(new DateTime(2001, 6, 1), 11),
new WeatherDataItem(new DateTime(2001, 7, 1), 13),
new WeatherDataItem(new DateTime(2001, 8, 1), 13),
new WeatherDataItem(new DateTime(2001, 9, 1), 11),
new WeatherDataItem(new DateTime(2001, 10, 1), 8),
new WeatherDataItem(new DateTime(2001, 11, 1), 5),
new WeatherDataItem(new DateTime(2001, 12, 1), 2)
};
}
}
public class WeatherDataItem {
public DateTime Month { get; }
public double Temperature { get; }
public WeatherDataItem(DateTime month, double temperature) {
this.Month = month;
this.Temperature = temperature;
}
}
Important
ChartView chooses the X-axis type depending on data in the first series. If you specify the axis X for the chart or an individual series, set the ChartView.AxisX or Series.AxisX property to an object that is compatible with the series’ data type (otherwise, the chart does not display the series).