Back to Devexpress

Gauge Class

dashboard-devexpress-dot-dashboardcommon-0484929f.md

latest6.3 KB
Original Source

Gauge Class

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

Namespace : DevExpress.DashboardCommon

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

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class Gauge :
    KpiElement
vb
Public Class Gauge
    Inherits KpiElement

The following members return Gauge objects:

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 code snippets demonstrate how to bind a Gauge dashboard item to data in code.

csharp
using System;
using System.Windows.Forms;
using DevExpress.DashboardCommon;

namespace Dashboard_CreateGauges {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1() {
            InitializeComponent();
        }
        private GaugeDashboardItem CreateGauges(DashboardObjectDataSource dataSource) {

            GaugeDashboardItem gauges = new GaugeDashboardItem();
            gauges.ViewType = GaugeViewType.CircularHalf;
            gauges.DataSource = dataSource;

            Gauge gauge = new Gauge();
            gauge.ActualValue = new Measure("Extended Price", SummaryType.Sum);
            gauges.Gauges.Add(gauge);

            gauges.SeriesDimensions.Add(new Dimension("Sales Person"));

            return gauges;
        }
        private void Form1_Load(object sender, EventArgs e) {

            dashboardViewer1.Dashboard = new Dashboard();

            DashboardObjectDataSource dataSource = new DashboardObjectDataSource();
            dashboardViewer1.AsyncDataLoading+=(s,ev) => {
                ev.Data = (new nwindDataSetTableAdapters.SalesPersonTableAdapter()).GetData();
            };
            dashboardViewer1.Dashboard.DataSources.Add(dataSource);

            GaugeDashboardItem gauges = CreateGauges(dataSource);
            dashboardViewer1.Dashboard.Items.Add(gauges);

            dashboardViewer1.ReloadData();
        }
    }
}
vb
Imports System
Imports System.Windows.Forms
Imports DevExpress.DashboardCommon

Namespace Dashboard_CreateGauges
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

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

            Dim gauges As New GaugeDashboardItem()
            gauges.ViewType = GaugeViewType.CircularHalf
            gauges.DataSource = dataSource

            Dim gauge As New Gauge()
            gauge.ActualValue = New Measure("Extended Price", SummaryType.Sum)
            gauges.Gauges.Add(gauge)

            gauges.SeriesDimensions.Add(New Dimension("Sales Person"))

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

            dashboardViewer1.Dashboard = New Dashboard()

            Dim dataSource As New DashboardObjectDataSource()
            AddHandler dashboardViewer1.AsyncDataLoading, Sub(s,ev)
                ev.Data = (New nwindDataSetTableAdapters.SalesPersonTableAdapter()).GetData()
            End Sub
            dashboardViewer1.Dashboard.DataSources.Add(dataSource)

            Dim gauges As GaugeDashboardItem = CreateGauges(dataSource)
            dashboardViewer1.Dashboard.Items.Add(gauges)

            dashboardViewer1.ReloadData()
        End Sub
    End Class
End Namespace

Implements

ICustomPropertyProvider

Inheritance

Object DataItemContainer NamedDataItemContainer KpiElement Gauge

See Also

Gauge Members

Providing Data

DevExpress.DashboardCommon Namespace