windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotcustomchartdatasourcedataeventargs-099d1de5.md
Gets a value representing the type of a PivotGrid control’s item to be represented in a ChartControl.
Namespace : DevExpress.XtraPivotGrid
Assembly : DevExpress.XtraPivotGrid.v25.2.dll
NuGet Package : DevExpress.Win.PivotGrid
public PivotChartItemType ItemType { get; }
Public ReadOnly Property ItemType As PivotChartItemType
| Type | Description |
|---|---|
| PivotChartItemType |
A PivotChartItemType enumeration value.
|
Available values:
| Name | Description |
|---|---|
| RowItem |
A row field value is processed to be represented in the chart control.
| | ColumnItem |
A column field value is processed to be represented in the chart control.
| | CellItem |
A data cell value is processed to be represented in the chart control.
|
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.
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);
}
}
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
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ItemType property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-customize-pivot-grid-data-before-displaying-it-in-a-chart-control/CS/Form1.cs#L55
PivotCustomChartDataSourceDataEventArgs e) {
if(e.ItemType == PivotChartItemType.RowItem) {
if(e.FieldValueInfo.Field == fieldCategoryName) {
winforms-customize-pivot-grid-data-before-displaying-it-in-a-chart-control/VB/Form1.vb#L58
Private Sub pivotGridControl1_CustomChartDataSourceData(ByVal sender As Object, ByVal e As PivotCustomChartDataSourceDataEventArgs)
If e.ItemType = PivotChartItemType.RowItem Then
If e.FieldValueInfo.Field Is fieldCategoryName Then
See Also
PivotCustomChartDataSourceDataEventArgs Class