Skip to main content

DateTimeAxisX.AggregationType Property

Gets or sets the function used to aggregate data. This is a bindable property.

Namespace: DevExpress.Maui.Charts

Assembly: DevExpress.Maui.Charts.dll

NuGet Package: DevExpress.Maui.Charts

Declaration

public AggregationType AggregationType { get; set; }

Property Value

Type Default Description
AggregationType Average

A value that indicates the aggregate function.

Available values:

Name Description
Average

Calculates the average value for a date-time interval to aggregate data.

Count

Calculates the number of non-null values within a date-time interval to aggregate data.

Max

Calculates the maximum value for a date-time interval to aggregate data.

Min

Calculates the minimum value for a date-time interval to aggregate data.

Sum

Calculates the summary for a date-time interval to aggregate data.

Remarks

If the measurement unit of series point arguments is more detailed than X-axis measurement units, the ChartView uses the Average aggregate function to group raw data values into points with a larger argument measurement unit. You can use the AggregationType property to select another aggregate function.

This example shows how the chart calculates the average monthly values for each quarter on the X-axis.

AggregationType - Average

using System;
using System.Collections.Generic;

namespace ChartExample {
    public class ViewModel {
        public List<DataItem> Data { get; }

        public ViewModel() {
            Data = new List<DataItem>() {
                new DataItem() { Argument = new DateTime(2020, 1, 1), Value = 3 },
                new DataItem() { Argument = new DateTime(2020, 2, 1), Value = 5 },
                new DataItem() { Argument = new DateTime(2020, 3, 1), Value = 7 },
                new DataItem() { Argument = new DateTime(2020, 4, 1), Value = 2 },
                new DataItem() { Argument = new DateTime(2020, 5, 1), Value = 6 },
                new DataItem() { Argument = new DateTime(2020, 6, 1), Value = 4 },
                new DataItem() { Argument = new DateTime(2020, 7, 1), Value = 1 },
                new DataItem() { Argument = new DateTime(2020, 8, 1), Value = 8 },
                new DataItem() { Argument = new DateTime(2020, 9, 1), Value = 3 },
                new DataItem() { Argument = new DateTime(2020, 10, 1), Value = 9 },
                new DataItem() { Argument = new DateTime(2020, 11, 1), Value = 4 },
                new DataItem() { Argument = new DateTime(2020, 12, 1), Value = 7 },
            };
        }
    }

    public class DataItem {
        public DateTime Argument { get; set; }
        public double Value { get; set; }
    }
}
<ContentPage
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:dxc="clr-namespace:DevExpress.Maui.Charts;assembly=DevExpress.Maui.Charts"
    xmlns:local="clr-namespace:ChartExample"
    x:Class="ChartExample.MainPage">
    <ContentPage.BindingContext>
        <local:ViewModel />
    </ContentPage.BindingContext>
    <dxc:ChartView>
        <dxc:ChartView.Series>
            <dxc:BarSeries>
                <dxc:BarSeries.Data>
                    <dxc:SeriesDataAdapter DataSource="{Binding Data}" 
                                           ArgumentDataMember="Argument">
                        <dxc:ValueDataMember Member="Value" Type="Value" />
                    </dxc:SeriesDataAdapter>
                </dxc:BarSeries.Data>
            </dxc:BarSeries>
        </dxc:ChartView.Series>
        <dxc:ChartView.AxisX>
            <dxc:DateTimeAxisX MeasureUnit="Quarter" /> 
        </dxc:ChartView.AxisX>
    </dxc:ChartView>
</ContentPage>
See Also