PivotCustomChartDataSourceDataEventArgs(PivotChartItemType, PivotChartItemDataMember, PivotFieldValueItem, PivotGridCellItem, Object) Constructor
Initializes a new instance of the PivotCustomChartDataSourceDataEventArgs class with the specified settings.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.XtraPivotGrid.v19.1.dll
Declaration
public PivotCustomChartDataSourceDataEventArgs(
PivotChartItemType itemType,
PivotChartItemDataMember itemDataMember,
PivotFieldValueItem fieldValueItem,
PivotGridCellItem cellItem,
object value
)
Parameters
Name | Type | Description |
---|---|---|
itemType | PivotChartItemType | A PivotChartItemType enumeration value specifying the type of a PivotGrid control’s item to be represented in a ChartControl. This value is assigned to the PivotCustomChartDataSourceDataEventArgs.ItemType property. |
itemDataMember | PivotChartItemDataMember | A PivotChartItemDataMember enumeration value specifying the type of a chart data member that will represent the current Pivot Grid Control item. This value is assigned to the PivotCustomChartDataSourceDataEventArgs.ItemDataMember property. |
fieldValueItem | PivotFieldValueItem | A DevExpress.XtraPivotGrid.Data.PivotFieldValueItem object. |
cellItem | PivotGridCellItem | A DevExpress.XtraPivotGrid.Data.PivotGridCellItem object. |
value | Object | A Object specifying the value to be displayed in a chart. This value is assigned to the PivotCustomChartDataSourceDataEventArgs.Value property. |
Remarks
Instances of the PivotCustomChartDataSourceDataEventArgs class are automatically created, initialized and passed to the PivotGridControl.CustomChartDataSourceData event handlers. Typically, there is no need to call this constructor directly from your code.
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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/customize-pivot-grid-controls-data-before-displaying-it-in-a-chart-control-e2214
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);
}
}