Skip to main content

PivotCustomChartDataSourceDataEventHandler Delegate

Represents a method that will handle the PivotGridControl.CustomChartDataSourceData event.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v24.1.dll

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

public delegate void PivotCustomChartDataSourceDataEventHandler(
    object sender,
    PivotCustomChartDataSourceDataEventArgs e
);

Parameters

Name Type Description
sender Object

The event source. This parameter identifies the PivotGridControl which raised the event.

e PivotCustomChartDataSourceDataEventArgs

A PivotCustomChartDataSourceDataEventArgs object which 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.

Example

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

For this, it is necessary to handle the PivotGridControl.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 Sub pivotGridControl1_CustomChartDataSourceData(ByVal sender As Object, _
                              ByVal e As PivotCustomChartDataSourceDataEventArgs) _
                          Handles pivotGridControl1.CustomChartDataSourceData
    If e.ItemType = PivotChartItemType.RowItem Then
        If e.FieldValueInfo.Field Is fieldCategoryName Then
            e.Value = CategoryEncodeTable(e.FieldValueInfo.Value.ToString())
        ElseIf e.FieldValueInfo.Field Is fieldProductName Then
            Dim product As String = ProductEncodeTable(e.FieldValueInfo.Value.ToString())
            Dim category As String = CategoryEncodeTable(e.FieldValueInfo.GetHigherLevelFieldValue(fieldCategoryName).ToString())
            e.Value = product & "["c & category & "]"c
        End If
    End If
    If e.ItemType = PivotChartItemType.ColumnItem Then
        If e.FieldValueInfo.ValueType = PivotGridValueType.GrandTotal Then
            e.Value = "Total Sales"
        End If
    End If
    If e.ItemType = PivotChartItemType.CellItem Then
        e.Value = Math.Round(Convert.ToDecimal(e.CellInfo.Value), 0)
    End If
End Sub
See Also