Charting for WinForms Programmer's Guide
Ranges

The range is a visual representation of an interval within a gauge. Ranges are commonly used to mark or emphasize specific zones on the scale. Often the end of the scale is a danger zone and a range can be used to indicate this. The following image illustrates an oval gauge with three ranges (red, yellow and green) specifying different zones on the scale.

The range interval is specified through the MinValue and MaxValue properties. The Alignment and Offset properties control the positioning and the StartWidth and EndWidth properties specify the size of the range. The range can be auto-sized to the scale by setting AutoSize to true. To learn more about the different alignment modes check the Ticks and Labels topic.

Appearance

The Fill and Stroke properties can be used to specify the appearance of the range. The stroke on the different sides of the range can be turned off by using the CapStart, CapEnd, StrokeInside and StrokeOutside properties.

Usage

The sample code below illustrates how to define and add ranges to an existing linear scale:

C#  Copy Code

var range1 = new Range()
{
    MinValue = 70,
    MaxValue = 80,
    StartWidth = new Length(0),
    EndWidth = new Length(5, LengthType.Relative),
    Fill = new MindFusion.Drawing.SolidBrush(Color.Yellow),
    Stroke = new MindFusion.Drawing.Pen(Color.DimGray),
    Alignment = Alignment.OuterOutside,
    Offset = new Length(-2),
    CapEnd = false
};
var range2 = new Range()
{
    MinValue = 80,
    MaxValue = 90,
    StartWidth = new Length(5, LengthType.Relative),
    EndWidth = new Length(10, LengthType.Relative),
    Fill = new MindFusion.Drawing.SolidBrush(Color.Orange),
    Stroke = new MindFusion.Drawing.Pen(Color.DimGray),
    Alignment = Alignment.OuterOutside,
    Offset = new Length(-2),
    CapStart = false,
    CapEnd = false
};
var range3 = new Range()
{
    MinValue = 90,
    MaxValue = 100,
    StartWidth = new Length(10, LengthType.Relative),
    EndWidth = new Length(15, LengthType.Relative),
    Fill = new MindFusion.Drawing.SolidBrush(Color.Red),
    Stroke = new MindFusion.Drawing.Pen(Color.DimGray),
    Alignment = Alignment.OuterOutside,
    Offset = new Length(-2),
    CapStart = false
};

linearScale.Ranges.Add(range1);
linearScale.Ranges.Add(range2);
linearScale.Ranges.Add(range3);

The linear gauge defined above will look like this: