Skip to main content

XRGauge Class

A control that allows you to embed graphical gauges in a report.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public class XRGauge :
    XRControl

Remarks

To add a gauge to a report, drag the XRGauge item from the DX:24.2: Report Controls Toolbox tab and drop the item onto the report.

report-control-gauge-1

Warning

The XRGauge export is unavailable in applications that use the System.Drawing.Common package v7 and higher in non-Windows environments.

Cusomize Appearance

The following properties allow you to customize the gauge appearance:

  • View Type

    Specifies whether a gauge is circular or linear.

  • View Style

    Specifies the style of the gauge.

    • Linear Gauge: Horizontal or Vertical.
    • Circular Gauge: Full, Half, Quarter Left, Quarter Right, or Three Fourth.
  • View Theme

    Specifies whether the gauge is light or dark.

  • Tickmark Count

    Specifies the number of tick marks on a gauge scale.

A linear horizontal dark gauge

A circular half light gauge

Note

The above XRGauge properties allow you to make basic changes to gauge appearance. Advanced gauge customization is available in code only. Refer to the following repository for information on advanced gauge customization: Advanced Gauge Customization

Set Values and Limits

The Actual Value property allows you to specify the value a gauge displays. The Target Value property sets the position of the target value marker. The Maximum and Minimum properties specify the gauge’s maximum and minimum value.

The following example shows a circular gauge whose Actual Value, Target Value, Maximum, and Minimum properties are set to 3, 7, 0, and 10 respectively.

Bind to Data

You can click the control’s smart tag to bind the gauge’s Actual Value, Target Value, Maximum, and Minimum properties to data. In the invoked action list, expand the drop-down Expression list for one of the properties and specify the data field or expression to which the property should be bound.

report-control-gauge-6

Create a Gauge in Code

The following example demonstrates how to create the XRGauge control in code and bind it to data. In this example, the report is bound to the Northwind database and the Product table is specified as a data member.

using DevExpress.XtraGauges.Core.Customization;
using DevExpress.XtraReports.UI;
//...

// Create a gauge and customize its appearance.
var gauge = new XRGauge() {
    ViewType = DashboardGaugeType.Linear,
    ViewStyle = DashboardGaugeStyle.Horizontal,
    ViewTheme = DashboardGaugeTheme.FlatDark,
    Minimum = 0, Maximum = 50
};

// Specify an expression for the gauge's "ActualValue" property.
gauge.ExpressionBindings.Add(
    new ExpressionBinding("ActualValue", "[UnitPrice]")
);

Implements

See Also