Back to Devexpress

ManualNumericScaleOptions.AggregateFunction Property

wpf-devexpress-dot-xpf-dot-charts-dot-manualnumericscaleoptions.md

latest9.6 KB
Original Source

ManualNumericScaleOptions.AggregateFunction Property

Gets or sets the function that is used to aggregate numeric axis data when one of the AxisX2D.NumericScaleOptions, AxisX3D.NumericScaleOptions, or CircularAxisX2D.NumericScaleOptions properties is set to ManualNumericScaleOptions.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public AggregateFunction AggregateFunction { get; set; }
vb
Public Property AggregateFunction As AggregateFunction

Property Value

TypeDescription
AggregateFunction

An AggregateFunction enumeration value.

|

Available values:

NameDescription
None

The aggregate function is not applied.

| | Average |

Aggregates data by calculating the average value for a selected numeric or date-time interval.

| | Minimum |

Aggregates data by calculating the minimum value for a selected numeric or date-time interval.

| | Maximum |

Aggregates data by calculating the maximum value for a selected numeric or date-time interval.

| | Sum |

Aggregates data by calculating the summary for a selected numeric or date-time interval.

| | Count |

Aggregates data by calculating the number of non-null values for a selected numeric or date-time interval.

| | Histogram |

Aggregates data by calculating the number of all points for a selected numeric or date-time interval.

| | Financial |

Aggregates financial data for a selected interval into a single high-low-open-close data point, so that the high value equals the highest value of all data points in this interval; the low value equals the lowest value of all data points; the open value equals the value of the first data point and the close value equals the value of the last data point.

| | Custom |

Aggregates data using the custom CustomAggregateFunction calculator.

|

Remarks

The image below shows numeric data aggregation in the Manual scale mode using the default Average function.

Note

The AggregateFunction property is set to AggregateFunction.Average by default.

To disable numeric data aggregation, set the AggregateFunction property to AggregateFunction.None.

To learn more, see Data Aggregation.

Example

This example demonstrates how to use the manual numeric scale options of the X-axis.

When the AxisX2D.NumericScaleOptions property is set to ManualNumericScaleOptions, you can manually define the ManualNumericScaleOptions.GridAlignment, ManualNumericScaleOptions.MeasureUnit and ManualNumericScaleOptions.AggregateFunction properties.

To use the automatic numeric scale options, set the AxisX2D.NumericScaleOptions property to AutomaticNumericScaleOptions and choose the appropriate AutomaticNumericScaleOptions.AggregateFunction.

To prevent the axis scale from being divided into intervals (and thus prevent chart data from being aggregated), set the ManualNumericScaleOptions.AggregateFunction or AutomaticNumericScaleOptions.AggregateFunction property to None.

xaml
<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" 
    x:Class="AggregationNumericData.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxc:ChartControl >
            <dxc:ChartControl.Legend>
                <dxc:Legend/>
            </dxc:ChartControl.Legend>
            <dxc:XYDiagram2D>
                <dxc:XYDiagram2D.AxisX>
                    <dxc:AxisX2D GridLinesVisible="True">
                        <dxc:AxisX2D.NumericScaleOptions>
                            <dxc:ManualNumericScaleOptions MeasureUnit="100" GridAlignment="1000" 
                                                           AggregateFunction="Maximum" GridSpacing="2"/>
                        </dxc:AxisX2D.NumericScaleOptions>
                    </dxc:AxisX2D>
                </dxc:XYDiagram2D.AxisX>
                <dxc:LineSeries2D DataSource="{Binding Path=Series}" 
                                  ArgumentDataMember="Argument" ValueDataMember="Value"/>
            </dxc:XYDiagram2D>
        </dxc:ChartControl>
    </Grid>
</Window>
vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Windows

Namespace AggregationNumericData
    Partial Public Class MainWindow
        Inherits Window
        Public Sub New()
            InitializeComponent()
            DataContext = New AggregationDataContext()
        End Sub
    End Class

    Public Class AggregationDataContext
        Private Const pointCount As Integer = 100000

        Private ReadOnly series_Renamed As New List(Of NumericPoint)()

        Public ReadOnly Property Series() As List(Of NumericPoint)
            Get
                Return series_Renamed
            End Get
        End Property

        Public Sub New()
            FillPoints(series_Renamed)
        End Sub

        Private Sub FillPoints(ByVal series As List(Of NumericPoint))
            If series IsNot Nothing Then
                Dim value As Double = 0
                Dim argument As Double = 0
                Dim random As New Random()

                For i As Double = 0 To pointCount - 1
                    series.Add(New NumericPoint(argument, value))
                    value += (random.NextDouble() * 10.0 - 5.0)
                    argument += random.NextDouble()
                Next i
            End If
        End Sub

    End Class

    Public Class NumericPoint
        Private ReadOnly argument_Renamed As Double
        Private ReadOnly value_Renamed As Double

        Public ReadOnly Property Argument() As Double
            Get
                Return argument_Renamed
            End Get
        End Property
        Public ReadOnly Property Value() As Double
            Get
                Return value_Renamed
            End Get
        End Property

        Public Sub New(ByVal argument As Double, ByVal value As Double)
            Me.argument_Renamed = argument
            Me.value_Renamed = value
        End Sub
    End Class
End Namespace
csharp
using System;
using System.Collections.Generic;
using System.Windows;

namespace AggregationNumericData
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new AggregationDataContext();
        }
    }

    public class AggregationDataContext
    {
        const int pointCount = 100000;

        readonly List<NumericPoint> series = new List<NumericPoint>();

        public List<NumericPoint> Series { get { return series; } }

        public AggregationDataContext()
        {
            FillPoints(series);
        }

        void FillPoints(List<NumericPoint> series)
        {
            if (series != null)
            {
                double value = 0;
                double argument = 0;
                Random random = new Random();

                for (double i = 0; i < pointCount; i++)
                {
                    series.Add(new NumericPoint(argument, value));
                    value += (random.NextDouble() * 10.0 - 5.0);
                    argument += random.NextDouble();
                }
            }
        }

    }

    public class NumericPoint
    {
        readonly double argument;
        readonly double value;

        public double Argument { get { return argument; } }
        public double Value { get { return value; } }

        public NumericPoint(double argument, double value)
        {
            this.argument = argument;
            this.value = value;
        }
    }
}

See Also

ManualNumericScaleOptions Class

ManualNumericScaleOptions Members

DevExpress.Xpf.Charts Namespace