LinearScale.Ranges Property
Provides access to the collection of custom ranges with which you can mark specific value ranges along the scale.
Namespace: DevExpress.XtraGauges.Core.Model
Assembly: DevExpress.XtraGauges.v24.2.Core.dll
NuGet Package: DevExpress.Gauges.Core
#Declaration
public virtual RangeCollection Ranges { get; }
#Property Value
Type | Description |
---|---|
Range |
A Range |
#Remarks
Custom ranges are fixed bars that are used to mark specific value ranges along scales. To create a custom range, add a DevExpress.XtraGauges.Core.Model.LinearScaleRange object to the Ranges collection. A LinearScaleRange object specifies the start and end value for the range, the color, the start and end thickness of the range and other options.
When a scale’s value falls into a specific range, the range’s Enter event raises. When the value leaves the range, the Leave event raises.
#Example
The following code shows how to add custom ranges to a linear gauge.
Two ranges are added to the LinearScale.Ranges
collection. These are used to mark values from 0 to 300 in green, and values between 300 and 500 in red. The result is displayed below:
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraGauges.Core.Drawing;
linearScaleComponent1.BeginUpdate();
// Range 1.
LinearScaleRange range1 = new LinearScaleRange();
range1.AppearanceRange.ContentBrush = new SolidBrushObject(Color.Red);
range1.StartValue = 300F;
range1.EndValue = 510F;
range1.ShapeOffset = -5F;
// Range 2.
LinearScaleRange range2 = new LinearScaleRange();
range2.AppearanceRange.ContentBrush = new SolidBrushObject(Color.Lime);
range2.StartValue = 0F;
range2.EndValue = 300F;
range2.ShapeOffset = -5F;
// Add the ranges to the scale.
linearScaleComponent1.Ranges.AddRange(new IRange[] {range1, range2 } );
linearScaleComponent1.EndUpdate();