PivotGridFieldBase.KPIGraphic Property

Gets or sets a graphic set used to indicate KPI values.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v20.1.Core.dll

Declaration

[DefaultValue(PivotKPIGraphic.ServerDefined)]
public PivotKPIGraphic KPIGraphic { get; set; }
<DefaultValue(PivotKPIGraphic.ServerDefined)>
Public Property KPIGraphic As PivotKPIGraphic

Property Value

Type Default Description
PivotKPIGraphic

ServerDefined

A PivotKPIGraphic enumeration value that specifies the graphic set used to indicate KPI values.

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).

Examples

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:

ex-WF-PivotGrid-RegularDataSorceKPI

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;

        }
    }
}
See Also