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

CustomAggregateFunction.Calculate(GroupInfo) Method

Calculates the aggregated values of the specified series point value group.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v19.1.dll

Declaration

public abstract double[] Calculate(
    GroupInfo groupInfo
)

Parameters

Name Type Description
groupInfo GroupInfo

Information about values that should be aggregated.

Returns

Type Description
Double[]

The array of data point values.

Remarks

The group info stores the following value collections in its properties:

Property Value Levels
GroupInfo.Values1 Value (for common and the bubble series), Value_1 (for range series), High (for financial series)
GroupInfo.Values2 Weight (for common and the bubble series), Value_2 (for range series), Low (for financial series)
GroupInfo.Values3 Open (for financial series)
GroupInfo.Values4 Close (for financial series)

The resulting array must contain values in the following order:

Series type Value order
For common series {Value}
For range series: {Value_1, Value_2}
For the bubble series: {Value, Weight}
For financial series: {High, Low, Open, Close}

Example

Set the CustomAggregateFunction class descendant object to the ScaleGridOptionsBase.CustomAggregateFunction property to use the custom aggregate function. Note that the ScaleGridOptionsBase.AggregateFunction property should be set to Custom.

private void Form1_Load(object sender, EventArgs e) {
    Series series = chartControl.Series["Random Data"];
    series.DataSource = GenerateData(100_000);
    series.ArgumentDataMember = "Argument";
    series.ValueDataMembers.AddRange("Value", "Value", "Value", "Value");

    XYDiagram diagram = chartControl.Diagram as XYDiagram;
    diagram.AxisX.DateTimeScaleOptions.AggregateFunction = AggregateFunction.Custom;
    diagram.AxisX.DateTimeScaleOptions.CustomAggregateFunction = new OhlcAggregateFunction();
}

class OhlcAggregateFunction : CustomAggregateFunction {
    public override double[] Calculate(GroupInfo groupInfo) {
        double open = groupInfo.Values1.First();
        double close = groupInfo.Values1.Last();
        double high = Double.MinValue;
        double low = Double.MaxValue;
        foreach (double value in groupInfo.Values1) {
            if (high < value) high = value;
            if (low > value) low = value;
        }

        return new double[] { high, low, open, close };
    }
}
See Also