Back to Devexpress

PivotGridFieldBase.KPIGraphic Property

corelibraries-devexpress-dot-xtrapivotgrid-dot-pivotgridfieldbase-ddcc40bc.md

latest11.3 KB
Original Source

PivotGridFieldBase.KPIGraphic Property

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

Namespace : DevExpress.XtraPivotGrid

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

NuGet Packages : DevExpress.PivotGrid.Core, DevExpress.Win.Navigation

Declaration

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

Property Value

TypeDefaultDescription
PivotKPIGraphicServerDefined

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

|

Available values:

Show 16 items

NameDescription
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

KPI supports graphic representation for its Status and Trend values. OLAP supports 12 graphic sets such as shapes, smiley faces, traffic lights, etc. Use the KPIGraphic property to specify the graphic set.

If the KPIGraphic property is not set to PivotKPIGraphic.ServerDefined, KPI graphics can be displayed for table data sources. In this instance, valid KPI values are &#0045;1 (bad), 0 (neutral), and 1 (good).

Refer to the following topic for more information: Key Performance Indicators (KPIs).

Example

The following example shows how to display KPI graphics in the Pivot Grid bound to the Northwind database. The image below illustrates the resulting UI.

View Example: Pivot Grid for WinForms - Display KPI Graphics

To display KPI graphics, create a Pivot Grid field and bind it to the following expression:

(Iif(Sum([{0}])<100000,-1,Iif(Sum([{0}])<150000,0,1)))", fieldExtendedPrice.ExpressionFieldName)

The field values depend on the Extended Price field values. If the Extended Price field value is less than 100000, the field value is -1. If the Extended Price field value is less than 150000, the field value is 0. In other cases, the field value is 1.

Use the PivotGridFieldBase.KPIGraphic property to specify a graphic set used to visualize field values.

cs
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);
            // Creates a new "Status" field to show KPI values.
            PivotGridField KPIField = pivotGridControl1.Fields.Add();
            KPIField.Area = PivotArea.DataArea;
            KPIField.Caption = "Status";
            // Sets a column's data binding and specifies an expression.
            KPIField.DataBinding = new ExpressionDataBinding(
                string.Format("(Iif(Sum([{0}])<100000,-1,Iif(Sum([{0}])<150000,0,1)))", 
                fieldExtendedPrice.ExpressionFieldName));
            // Sets the Data Header Area within which the "Status" Field can be positioned.
            KPIField.AllowedAreas = DevExpress.XtraPivotGrid.PivotGridAllowedAreas.DataArea;
            // Specifies a graphic set used to indicate KPI values.
            KPIField.KPIGraphic = PivotKPIGraphic.Faces;
        }
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraPivotGrid

Namespace WindowsFormsApp_RegularDataSourceKPI

    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' Binds the Pivot Grid to data.
            salesPersonTableAdapter.Fill(nwindDataSet.SalesPerson)
            ' Creates a new "Status" field to show KPI values.
            Dim KPIField As PivotGridField = pivotGridControl1.Fields.Add()
            KPIField.Area = PivotArea.DataArea
            KPIField.Caption = "Status"
            ' Sets a column's data binding and specifies an expression.
            KPIField.DataBinding = New ExpressionDataBinding(String.Format("(Iif(Sum([{0}])<100000,-1,Iif(Sum([{0}])<150000,0,1)))", fieldExtendedPrice.ExpressionFieldName))
            ' Sets the Data Header Area within which the "Status" Field can be positioned.
            KPIField.AllowedAreas = PivotGridAllowedAreas.DataArea
            ' Specifies a graphic set used to indicate KPI values.
            KPIField.KPIGraphic = PivotKPIGraphic.Faces
        End Sub
    End Class
End Namespace

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.

winforms-pivot-grid-display-kpi-graphics/CS/WindowsFormsApp_RegularDataSourceKPI/Form1.cs#L24

csharp
// Specifies a graphic set used to indicate KPI values.
    KPIField.KPIGraphic = PivotKPIGraphic.Faces;
}

winforms-pivot-grid-display-kpi-graphics/VB/WindowsFormsApp_RegularDataSourceKPI/Form1.vb#L26

vb
' Specifies a graphic set used to indicate KPI values.
    KPIField.KPIGraphic = PivotKPIGraphic.Faces
End Sub

See Also

GetOLAPKPIServerGraphic(String, PivotKPIType)

KPIType

PivotGridFieldBase Class

PivotGridFieldBase Members

DevExpress.XtraPivotGrid Namespace