XRChart.RegisterGlobalSummaryFunction(String, String, Nullable<ScaleType>, Int32, SummaryFunctionArgumentDescription[], SummaryFunction) Method
Registers the custom summary function with the specified settings for all XRChart controls in the application.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
public static void RegisterGlobalSummaryFunction(
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 | Nullable<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 RegisterGlobalSummaryFunction method is intended to register custom summary functions to be used by all chart controls in the application.
To unregister a specific summary function, call the UnregisterGlobalSummaryFunction(String) method.
The following example demonstrates how to create a custom summary function that returns a product of two values (Price * Count). To accomplish this task, it is required to create a summary function delegate and register it via the RegisterGlobalSummaryFunction method.
using DevExpress.XtraCharts;
using DevExpress.XtraReports.UI;
//...
static class Program {
// 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();
}
static void Main() {
//...
XRChart.RegisterGlobalSummaryFunction("PRODUCT", "PRODUCT", ScaleType.Auto, 1,
new SummaryFunctionArgumentDescription[] {
new SummaryFunctionArgumentDescription("Price", ScaleType.Numerical),
new SummaryFunctionArgumentDescription("Count", ScaleType.Numerical)},
CalculateProductValue);
//...
}
}
Now, you can assign the registered function to the series’s SummaryFunction property.