PivotGridFieldBase.KPIGraphic Property
Gets or sets a graphic set used to indicate KPI values.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.PivotGrid.v19.2.Core.dll
Declaration
[DefaultValue(PivotKPIGraphic.ServerDefined)]
public PivotKPIGraphic KPIGraphic { get; set; }
Property Value
Type | Default | Description |
---|---|---|
PivotKPIGraphic | **ServerDefined** | A PivotKPIGraphic enumeration value that specifies the graphic set used to indicate KPI values. |
Available values:
Name | Description |
---|---|
None | No image is displayed. |
ServerDefined | The KPI graphic type is defined by the server. |
Shapes | |
TrafficLights | |
RoadSigns | |
Gauge | |
ReversedGauge | |
Thermometer | |
ReversedThermometer | |
Cylinder | |
ReversedCylinder | |
Faces | |
VarianceArrow | |
StandardArrow | |
StatusArrow | |
ReversedStatusArrow |
Remarks
Since KPI supports graphic representation for its Status and Trend values, these values can be replaced with images. OLAP supports 12 graphic sets such as shapes, smiley faces, traffic lights, etc. Use the KPIGraphic property to specify the required graphic set.
If the KPIGraphic property is not set to PivotKPIGraphic.ServerDefined, KPI graphics can be displayed for table data sources, as well. In this instance, valid KPI values are -1 (bad), 0 (neutral) and 1 (good).
To learn more, see Key Performance Indicators (KPIs).
Example
The following example shows how to display KPI graphics in a PivotGridControl bound to a regular data source.
The Pivot Grid Control is bound to the “Sales Person” view in the Northwind database. To display KPI graphics, we create an unbound field whose values correspond to images contained within a KPI graphic set.
In this example, the unbound field values depend on the “Extended Price” field values: if the “Extended Price” field value is less than 100,000, the unbound field value is “-1”, if the “Extended Price” field value is less than 150,000, the unbound field value is “0”. In other cases, the unbound field value is “1”.
The PivotGridOptionsData.DataFieldUnboundExpressionMode property is set to DataFieldUnboundExpressionMode.UseSummaryValues to calculate unbound expressions for data fields against summary values. The PivotGridFieldBase.KPIGraphic
property specifies a graphic set used to visualize unbound field values.
The following image shows the result of the KPI values visualization:
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-display-kpi-graphics-in-pivotgridcontrol-bound-to-a-regular-data-source-t152365
using System;
using System.Windows.Forms;
using DevExpress.XtraPivotGrid;
namespace WindowsFormsApp_RegularDataSourceKPI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Binds the pivot grid to data.
this.salesPersonTableAdapter.Fill(this.nwindDataSet.SalesPerson);
// Specifies that unbound expressions for data fields are calculated against summary values.
pivotGridControl1.OptionsData.DataFieldUnboundExpressionMode =
DataFieldUnboundExpressionMode.UseSummaryValues;
// Creates a new unbound "Status" field to show KPI values.
PivotGridField unboundField = pivotGridControl1.Fields.Add("Status", PivotArea.DataArea);
// Sets a column's unbound type and specifies an unbound expression.
unboundField.UnboundType = DevExpress.Data.UnboundColumnType.Integer;
unboundField.UnboundExpression =
string.Format("(Iif([{0}]<100000,-1,Iif([{0}]<150000,0,1)))",
fieldExtendedPrice1.ExpressionFieldName);
// Sets the Data Header Area within which the "Status" Field can be positioned.
unboundField.AllowedAreas = DevExpress.XtraPivotGrid.PivotGridAllowedAreas.DataArea;
// Specifies a graphic set used to indicate KPI values.
unboundField.KPIGraphic = PivotKPIGraphic.Faces;
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the KPIGraphic 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.