Skip to main content

ASPxPivotGrid.CustomChartDataSourceData Event

Occurs when a ASPxPivotGrid prepares data to be displayed in a WebChartControl.

Namespace: DevExpress.Web.ASPxPivotGrid

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

NuGet Package: DevExpress.Web

Declaration

public event PivotCustomChartDataSourceDataEventHandler CustomChartDataSourceData

Event Data

The CustomChartDataSourceData event's data class is PivotCustomChartDataSourceDataEventArgs. The following properties provide information specific to this event:

Property Description
CellInfo Gets an object which contains information about a ASPxPivotGrid control’s cell, whose value should be displayed in a WebChartControl.
FieldValueInfo Gets an object which contains information about a field value to be displayed in a WebChartControl.
ItemDataMember Gets the type of a chart data member that will represent the current pivot grid item.
ItemType Gets a value representing the type of an ASPxPivotGrid control’s item to be represented in a WebChartControl.
Value Gets or sets a value to be displayed in a WebChartControl.

Example

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.

View Example

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