Back to Devexpress

XRChart.RegisterGlobalSummaryFunction(String, String, Nullable<ScaleType>, Int32, SummaryFunctionArgumentDescription[], SummaryFunction) Method

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrchart-dot-registerglobalsummaryfunction-x28-string-string-nullable-scaletype-int32-summaryfunctionargumentdescription-summaryfunction-x29.md

latest6.6 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public static void RegisterGlobalSummaryFunction(
    string name,
    string displayName,
    ScaleType? resultScaleType,
    int resultDimension,
    SummaryFunctionArgumentDescription[] argumentDescriptions,
    SummaryFunction function
)
vb
Public Shared Sub RegisterGlobalSummaryFunction(
    name As String,
    displayName As String,
    resultScaleType As ScaleType?,
    resultDimension As Integer,
    argumentDescriptions As SummaryFunctionArgumentDescription(),
    function As SummaryFunction
)

Parameters

NameTypeDescription
nameString

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.

csharp
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);
    //...
  }
}
vb
Imports DevExpress.XtraCharts
Imports DevExpress.XtraReports.UI
'...
Friend Module Program
  ' Declare the Product summary function.
  Private Function CalculateProductValue(ByVal series As Series, ByVal argument As Object, ByVal functionArguments() As String, ByVal values() As DataSourceValues, ByVal colors() As Object) As SeriesPoint()

    ' Create an array of the resulting series points.
    Dim points As New List(Of SeriesPoint)()
    ' Calculate the resulting series points as Price * Count.
    For i As Integer = 0 To values.Length - 1
      Dim value As Double = Convert.ToDouble(values(i)(functionArguments(0))) * Convert.ToDouble(values(i)(functionArguments(1)))
      If value > 0 Then
        points.Add(New SeriesPoint(argument, value))
      End If
    Next i
    ' Return the result.
    Return points.ToArray()
  End Function
  Sub Main()
    '...
    XRChart.RegisterGlobalSummaryFunction("PRODUCT", "PRODUCT", ScaleType.Auto, 1, New SummaryFunctionArgumentDescription() {
        New SummaryFunctionArgumentDescription("Price", ScaleType.Numerical),
        New SummaryFunctionArgumentDescription("Count", ScaleType.Numerical)
    }, AddressOf CalculateProductValue)
    '...
  End Sub
End Module

Now, you can assign the registered function to the series’s SummaryFunction property.

See Also

Calculate Summaries

XRChart Class

XRChart Members

DevExpress.XtraReports.UI Namespace