Skip to main content

IXYSeriesData Interface

An interface that should be implemented by an object that supplies data for the chart’s series.

Namespace: DevExpress.Maui.Charts

Assembly: DevExpress.Maui.Charts.dll

NuGet Package: DevExpress.Maui.Charts

Declaration

public interface IXYSeriesData

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

Qualitative

GetQualitativeArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value.

Numeric

GetNumericArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value.

DateTime

GetDateTimeArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value.

WeightedQualitative

GetQualitativeArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value and Weight.

WeightedNumeric

GetNumericArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value and Weight.

WeightedDateTime

GetDateTimeArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value and Weight.

RangeQualitative

GetQualitativeArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value1 and Value2.

RangeNumeric

GetNumericArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value1 and Value2.

RangeDateTime

GetDateTimeArgument(Int32); GetValue(ValueType, Int32) with the value type set to Value1 and Value2.

Financial

GetDateTimeArgument(Int32); GetValue(ValueType, Int32) with the value type set to Open, High, Low and Close.

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 populates 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.Maui.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

LineSeries

Displays data as points connected by a line.

LineSeries.Data

Gets or sets the series data.

IXYSeriesData

An interface that should be implemented by an object that supplies data for the chart’s series.

See Also