PivotCustomChartDataSourceDataEventHandler Delegate

A method that will handle the ASPxPivotGrid.CustomChartDataSourceData event.

Namespace: DevExpress.Web.ASPxPivotGrid

Assembly: DevExpress.Web.ASPxPivotGrid.v19.2.dll

Declaration

public delegate void PivotCustomChartDataSourceDataEventHandler(
    object sender,
    PivotCustomChartDataSourceDataEventArgs e
);
Public Delegate Sub PivotCustomChartDataSourceDataEventHandler(
    sender As Object,
    e As PivotCustomChartDataSourceDataEventArgs
)

Parameters

Name Type Description
sender Object

The event source. This parameter identifies the pivot grid which raised the event.

e PivotCustomChartDataSourceDataEventArgs

A PivotCustomChartDataSourceDataEventArgs object that contains event data.

Remarks

When creating a PivotCustomChartDataSourceDataEventHandler delegate, you identify the method that will handle the corresponding event. To associate an event with your event handler, add a delegate instance to this event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see Events and Delegates in MSDN.

Examples

The following example demonstrates how to add custom text to data prepared by the ASPxPivotGrid, to display it in a WebChartControl.

For this, it is necessary to handle the ASPxPivotGrid.CustomChartDataSourceData event. In this event handler, you can determine the item type via the PivotCustomChartDataSourceDataEventArgs.ItemType property and change the PivotCustomChartDataSourceDataEventArgs.Value according to your custom requirements.

private void pivotGridControl1_CustomChartDataSourceData(object sender, 
PivotCustomChartDataSourceDataEventArgs e) {
    if(e.ItemType == PivotChartItemType.RowItem) {
        if(e.FieldValueInfo.Field == fieldCategoryName) {
            e.Value = CategoryEncodeTable[e.FieldValueInfo.Value.ToString()];
        } else if(e.FieldValueInfo.Field == fieldProductName) {
            string product =  
                ProductEncodeTable[e.FieldValueInfo.Value.ToString()];
            string category = 
            CategoryEncodeTable[e.FieldValueInfo.GetHigherLevelFieldValue(fieldCategoryName).ToString()];
            e.Value = product + '[' + category + ']';
        }
    }
    if(e.ItemType == PivotChartItemType.ColumnItem) {
        if(e.FieldValueInfo.ValueType == PivotGridValueType.GrandTotal) {
            e.Value = "Total Sales";
        }
    }
    if(e.ItemType == PivotChartItemType.CellItem) {
        e.Value = Math.Round(Convert.ToDecimal(e.CellInfo.Value), 0);
    }
}
See Also