Back to Devexpress

PivotCustomChartDataSourceDataEventArgs.Value Property

wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotcustomchartdatasourcedataeventargs-7f75f64f.md

latest4.3 KB
Original Source

PivotCustomChartDataSourceDataEventArgs.Value Property

Gets or sets a value to be displayed in a ChartControl.

Namespace : DevExpress.Xpf.PivotGrid

Assembly : DevExpress.Xpf.PivotGrid.v25.2.dll

NuGet Package : DevExpress.Wpf.PivotGrid

Declaration

csharp
public object Value { get; set; }
vb
Public Property Value As Object

Property Value

TypeDescription
Object

A Object class descendant representing the value to be displayed.

|

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

vb
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
csharp
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

PivotCustomChartDataSourceDataEventArgs Class

PivotCustomChartDataSourceDataEventArgs Members

DevExpress.Xpf.PivotGrid Namespace