IXYSeriesData Interface
An interface that should be implemented by an object that supplies data for the chart’s series.
Namespace: DevExpress.XamarinForms.Charts
Assembly: DevExpress.XamarinForms.Charts.dll
NuGet Package: DevExpress.XamarinForms.Charts
Declaration
public interface IXYSeriesData
Related API Members
The following members return IXYSeriesData objects:
Remarks
Assign objects that implement this interface to the Data property of Area, Line, Bar, Point, Bubble, RangeBar, RangeArea and Financial series to supply user data values for series that the ChartView displays.
Each series type can display data of specific data types only (the GetDataType() method’s return value):
Series Type | GetDataType Return Value |
---|---|
Area Series | Qualitative , Numeric , DateTime |
Line Series | Qualitative , Numeric , DateTime |
Bar Series | Qualitative , Numeric , DateTime |
Point Series | Qualitative , Numeric , DateTime |
Bubble Series | WeightedQualitative , WeightedNumeric , WeightedDateTime |
Range Series | RangeQualitative , RangeNumeric , RangeDateTime |
Financial Series | Financial |
The IXYSeriesData interface has the GetValue
method and a set of GetArgument
methods that return values used to plot a series on the chart. A value type parameter of the GetValue
method and the GetArgument
method that the series calls depend on the data type the interface returns:
Data Type | Called Methods and Their Arguments |
---|---|
| GetQualitativeArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetNumericArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetDateTimeArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetQualitativeArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetNumericArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetDateTimeArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetQualitativeArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetNumericArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetDateTimeArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
| GetDateTimeArgument(Int32);
GetValue(ValueType, Int32) with the value type set to |
The series data type should be compatible with the chart’s X-axis type as the following table shows:
Axis | Series Data Type |
---|---|
QualitativeAxisX | Qualitative , WeightedQualitative , RangeQualitative |
NumericAxisX | Numeric , WeightedNumeric , RangeNumeric |
DateTimeAxisX | DateTime , WeightedDateTime , RangeDateTime , Financial |
Note
The chart automatically chooses the X-axis type depending on data in the first series if you do not specify an axis explicitly.
Example
This example demonstrates how to populate a line series with data:
<dxc:ChartView.Series>
<dxc:LineSeries DisplayName="Stock">
<dxc:LineSeries.Data>
<data:StockSeriesData ItemsSource="{Binding Prices}"/>
</dxc:LineSeries.Data>
</dxc:LineSeries>
</dxc:ChartView.Series>
using DXC = DevExpress.XamarinForms.Charts;
public class StockSeriesData : BindableObject, IXYSeriesData {
public const string ItemsSourcePropertyName = "ItemsSource";
public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(
propertyName: ItemsSourcePropertyName,
returnType: typeof(IReadOnlyList<StockPrice>),
declaringType: typeof(StockSeriesData),
defaultValue: null);
public IReadOnlyList<StockPrice> ItemsSource {
get => (IReadOnlyList<StockPrice>)GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
public SeriesDataType GetDataType() => SeriesDataType.DateTime;
public int GetDataCount() => ItemsSource.Count;
public DateTime GetDateTimeArgument(int index) => ItemsSource[index].Date;
public double GetValue(DXC.ValueType valueType, int index) {
switch (valueType) {
case DXC.ValueType.Value: return ItemsSource[index].Close;
default: return 0;
}
}
public object GetKey(int index) => ItemsSource[index];
public double GetNumericArgument(int index) => 0;
public string GetQualitativeArgument(int index) => string.Empty;
}
The code above uses the following classes and members:
Symbol | Description |
---|---|
Displays data as points connected by a line. | |
Gets or sets the series data. | |
| An interface that should be implemented by an object that supplies data for the chart’s series. |