Skip to main content
A newer version of this page is available. .

Data Aggregation

  • 5 minutes to read

This document explains the concept of data aggregation, and how to customize this feature for date-time and numeric data.

The document consists of the following sections.

Overview

Data aggregation is useful when your charts display a very large amount of data (e.g., thousands or even millions of data points), and it is necessary to show a quick aggregated view of this data.

The image below shows a chart with non-aggregated data.

NonAggregatedChart

When data aggregation is enabled in the chart control, the chart will split the entire X-axis into intervals (according to the measure unit value), and automatically aggregate data for each interval.

Note

Data aggregation is available for the argument axis (X-axis) only, and neither the value axis (Y-axis) nor the secondary axes have this property.

The following image shows chart data aggregated by year.

YearAggregation

The data aggregation feature provides three scale modes (ScaleOptionsBase.ScaleMode) for both date-time and numeric data.

The sections below detail the specifics of using the aggregation feature for date-time and numeric data.

Aggregate Function

Data for each interval on the X-axis is aggregated using the function specified by the ScaleGridOptionsBase.AggregateFunction property (available both in ScaleMode.Automatic and ScaleMode.Manual scale modes). Although by default, aggregate function is set to AggregateFunction.Average, it can be changed to any function lists in the AggregateFunction enumeration.

The table below shows data aggregation in the ScaleMode.Automatic scale mode using the AggregateFunction.Minimum and AggregateFunction.Sum functions.

Property value Resulting image
ScaleGridOptionsBase.AggregateFunction = AggregateFunction.Minimum Auto_MinimumAggregation
ScaleGridOptionsBase.AggregateFunction = AggregateFunction.Sum Auto_SumAggregation

In automatic date-time scale mode, the DateTimeOptions.Format and DateTimeOptions.FormatString properties are calculated automatically. Their values can be obtained in the ChartControl.AxisScaleChanged event handler.

This event also allows you to obtain the values calculated for an axis grid alignment unit and a measure unit, and also allows you to access other properties of the axis. For a code example, refer to How to: Obtain Values Calculated for Automatic Axis Date-Time Scale Modes.

Note

When the Aggregate function is set to None, all series are grouped against point arguments and the arithmetic operation is not applied to data.

If you specify the summary function, the aggregate function can’t be applied to data.

If you wish to disable aggregation, set the ScaleOptionsBase.ScaleMode property to Continuous. In this mode, an axis scale is not divided into intervals, and therefore aggregation cannot be applied to chart data.

Note

Only Continuous mode is available for a Gantt series because their values intrinsically have the date-time scale type, when only the numeric value scale type is required.

Date-time Data

For date-time data on the X-axis, data aggregation is enabled by default, and the date-time ScaleOptionsBase.ScaleMode is ScaleMode.Manual. In this mode, the DateTimeScaleOptions.GridAlignment and DateTimeScaleOptions.MeasureUnit properties are available. These properties allow you to define the output format of date-time values shown by the axis labels. The following image illustrates these options.

DefaultDateTimeAggregation

For instance, you can use the DateTimeScaleOptions.MeasureUnit property to determine the detail level for date-time values. Predefined measure units for date-time scales are stored in the DateTimeMeasurementUnit and their values are DateTimeMeasurementUnit.Millisecond, DateTimeMeasurementUnit.Second, DateTimeMeasurementUnit.Minute, DateTimeMeasurementUnit.Hour, DateTimeMeasurementUnit.Day, DateTimeMeasurementUnit.Week, DateTimeMeasurementUnit.Month, DateTimeMeasurementUnit.Quarter and DateTimeMeasurementUnit.Year.

The following table shows data aggregation for the measure unit set to DateTimeMeasurementUnit.Quarter and DateTimeMeasurementUnit.Year.

Property value Resulting image
DateTimeScaleOptions.MeasureUnit = DateTimeMeasurementUnit.Quarter MeasureUnit_Quarter
DateTimeScaleOptions.MeasureUnit = DateTimeMeasurementUnit.Year MeasureUnit_Year

Note

To use a custom Date-Time measure unit in a Automatic scale mode, assign an object of a class implementing the IDateTimeMeasureUnitsCalculator interface to the DateTimeScaleOptions.AutomaticMeasureUnitsCalculator property. Refer to the How to: Use Custom Measure Units in an Automatic Date-Time Scale Mode example to learn more.

Numeric Data

Data aggregation is disabled for the numeric scale type because the scale mode is set to ScaleMode.Continuous by default.

Non-AggregatedNumericScale

To enable this feature, you need to change the current scale mode to either ScaleMode.Manual or ScaleMode.Automatic.

The following image shows data aggregation in ScaleMode.Automatic scale mode using the default AggregateFunction.Average function.

AutomaticNumericScaleMode

If the AggregateFunction.Average aggregate function does not meet your business requirements, you can apply another function using the ScaleGridOptionsBase.AggregateFunction property (also available in ScaleMode.Manual scale mode).

In ScaleMode.Manual scale mode, it is possible to use one of the measure units that are listed in the NumericMeasureUnit; the predefined measure units are NumericMeasureUnit.Ones, NumericMeasureUnit.Tens, NumericMeasureUnit.Hundreds, NumericMeasureUnit.Thousands, NumericMeasureUnit.Millions and NumericMeasureUnit.Billions. In addition, you can specify a custom measure unit using the NumericScaleOptions.CustomMeasureUnit property when the NumericScaleOptions.MeasureUnit property is set to NumericMeasureUnit.Custom.

The following table shows data aggregation of a random function for a measure unit set to NumericMeasureUnit.Hundreds and NumericMeasureUnit.Thousands.

Property value Resulting image
NumericScaleOptions.MeasureUnit = NumericMeasureUnit.Hundreds NumericAggregation_Hundreds
NumericScaleOptions.MeasureUnit = NumericMeasureUnit.Thousands NumericAggregation_Thousands

Note

To use a custom numeric measure unit in a Automatic scale mode, assign an object of a class implementing the INumericMeasureUnitsCalculator interface to the NumericScaleOptions.AutomaticMeasureUnitsCalculator property. Refer to the How to: Use Custom Measure Units in an Automatic Numeric Scale Mode example to learn more.

See Also