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

WebChartControl.RegisterSummaryFunction(String, String, ScaleType, Int32, SummaryFunctionArgumentDescription[], SummaryFunction) Method

Registers the custom summary function with the specified settings.

Namespace: DevExpress.XtraCharts.Web

Assembly: DevExpress.XtraCharts.v18.2.Web.dll

Declaration

public void RegisterSummaryFunction(
    string name,
    string displayName,
    ScaleType resultScaleType,
    int resultDimension,
    SummaryFunctionArgumentDescription[] argumentDescriptions,
    SummaryFunction function
)

Parameters

Name Type Description
name String

A String value containing the function’s name.

displayName String

A String value containing the function’s display name, which is used for localization purposes.

resultScaleType ScaleType

A ScaleType enumeration value representing the type of the function’s result.

resultDimension Int32

An integer value representing the dimension of the resulting series point’s values.

argumentDescriptions SummaryFunctionArgumentDescription[]

An array of SummaryFunctionArgumentDescription objects containing argument descriptions.

function SummaryFunction

A SummaryFunction delegate to be registered.

Remarks

The RegisterSummaryFunction method is intended to register custom summary functions within a chart control. To unregister a specific summary function, the WebChartControl.UnregisterSummaryFunction method should be called. Also, you may remove all custom summary functions from the chart, and add all default functions to it by calling the WebChartControl.ResetSummaryFunctions method.

Example

The following example demonstrates how to create a custom summary function, which returns a product of two values (Price * Count). To accomplish this task, it is required to create a summary function delegate and register it using the WebChartControl.RegisterSummaryFunction method.

The code below illustrates how this can be done.

using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.XtraCharts;

namespace RegisterSummaryFunctionExample {
    public partial class WebForm1 : System.Web.UI.Page {
        const string summaryFunctionName = "PRODUCT";

        // Declare the Product summary function.
        private static SeriesPoint[] CalculateProductValue(
            Series series,
            object argument,
            string[] functionArguments,
            DataSourceValues[] values,
            object[] colors) {

            // Create an array of the resulting series points.
            List<SeriesPoint> points = new List<SeriesPoint>();
            // Calculate the resulting series points as Price * Count.
            for (int i = 0; i < values.Length; i++) {
                double value = Convert.ToDouble(values[i][functionArguments[0]]) *
                    Convert.ToDouble(values[i][functionArguments[1]]);
                if (value > 0)
                    points.Add(new SeriesPoint(argument, value));
            }
            // Return the result.
            return points.ToArray();
        }

        String BuildSummaryFunction(String price, String count) {
            return 
                new StringBuilder(summaryFunctionName)
                    .Append("([")
                    .Append(price)
                    .Append("],[")
                    .Append(count)
                    .Append("])")
                    .ToString();
        }

        protected void Page_Load(object sender, EventArgs e) {
            // Register the summary function in a chart.
            chartControl.RegisterSummaryFunction(summaryFunctionName, summaryFunctionName, 1,
                new SummaryFunctionArgumentDescription[] { 
                    new SummaryFunctionArgumentDescription("Price", ScaleType.Numerical), 
                    new SummaryFunctionArgumentDescription("Count", ScaleType.Numerical)},
                CalculateProductValue);

            // Specify the summary function for the series.
            Series series = chartControl.Series["Product"];
            series.SummaryFunction = BuildSummaryFunction("UnitPrice", "UnitsOnOrder");
        }
    }
}
See Also