Skip to main content
A newer version of this page is available. .

Gauge Class

Contains measures that provide data for a gauge in the GaugeDashboardItem.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v19.1.Core.dll

Declaration

public class Gauge :
    KpiElement

Remarks

Gauges displayed within the GaugeDashboardItem show the actual and target value of a particular parameter, as well as the difference between them. Data used to calculate the actual and target values is provided by a pair of measures - one Measure for each value.

The Gauge objects stored in the GaugeDashboardItem.Gauges collection specify these measures via the KpiElement.ActualValue and KpiElement.TargetValue properties.

The GaugeDashboardItem creates one gauge for each Gauge object in the GaugeDashboardItem.Gauges collection. If the SeriesDashboardItem.SeriesDimensions collection is not empty, multiple gauges are created for each Gauge object - one gauge for each dimension value. To learn more, see GaugeDashboardItem.Gauges.

Example

The following example demonstrates how to bind a Gauge dashboard item to data in code.

Imports System
Imports System.Windows.Forms
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess

Namespace Dashboard_CreateGauges
    Partial Public Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub
        Private Function CreateGauges(ByVal dataSource As DashboardObjectDataSource) As GaugeDashboardItem

            ' Creates a gauge dashboard item and specifies its data source.
            Dim gauges As New GaugeDashboardItem()
            gauges.DataSource = dataSource

            ' Creates the Gauge object with measures that provide data for calculating actual and target
            ' values, and then adds this object to the Gauges collection of the gauge dashboard item.
            Dim gauge As New Gauge()
            gauge.ActualValue = New Measure("Extended Price", SummaryType.Average)
            gauge.TargetValue = New Measure("Extended Price", SummaryType.Max)
            gauges.Gauges.Add(gauge)

            ' Specifies the dimension that provides data for a gauge dashboard item series.
            gauges.SeriesDimensions.Add(New Dimension("Sales Person"))

            Return gauges
        End Function
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load

            ' Creates a dashboard and sets it as the currently opened dashboard in the dashboard viewer.
            dashboardViewer1.Dashboard = New Dashboard()

            ' Creates a data source and adds it to the dashboard data source collection.
            Dim dataSource As New DashboardObjectDataSource()
            dataSource.DataSource = (New nwindDataSetTableAdapters.SalesPersonTableAdapter()).GetData()
            dashboardViewer1.Dashboard.DataSources.Add(dataSource)

            ' Creates a gauge dashboard item with the specified data source 
            ' and adds it to the Items collection to display within the dashboard.
            Dim gauges As GaugeDashboardItem = CreateGauges(dataSource)
            dashboardViewer1.Dashboard.Items.Add(gauges)

            ' Reloads data in the data sources.
            dashboardViewer1.ReloadData()
        End Sub
    End Class
End Namespace
See Also