Chart for .NET / User's Guide / Gauges / Indicators / Range Indicator

Range Indicator

Range indicators are useful when you have to highlight important ranges of data on the gauge axis. Furthermore range indicators can have different begin and end width that can be used to visually highlight the importance of different values within the range.

 Range

The range indicator has three properties that combined determine the scale range of the indicator. The first one is called Value and it controls either the begin or end value of the range depending of which one is bigger.

The OriginMode property allows you to anchor the range to the scale min, scale max or a custom value as shown by the following table:

Range indicator with origin set to ScaleMax and Value set to 80 Range indicator with origin set to ScaleMin and Value set to 80 Range indicator with origin set to Custom, Value set to 80 and Custom set to 20

The following code will create two range indicators – the first one spans [ScaleMin, 20] and the second one spans [80, ScaleMax]:

C#
Copy Code
nChartControl1.Panels.Clear();
NRadialGaugePanel radialGauge = new NRadialGaugePanel();
nChartControl1.Panels.Add(radialGauge);
radialGauge.ContentAlignment = ContentAlignment.BottomRight;
radialGauge.Size = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage));
radialGauge.Location = new NPointL(new NLength(0), new NLength(0));
radialGauge.SweepAngle = 270;
radialGauge.PaintEffect = new NGlassEffectStyle();
radialGauge.BorderStyle = new NEdgeBorderStyle(BorderShape.Auto);
NAdvancedGradientFillStyle ags = new NAdvancedGradientFillStyle();
ags.BackgroundColor = Color.Black;
ags.Points.Add(new NAdvancedGradientPoint(Color.LightGray, 50, 50, 0, 100, AGPointShape.Circle));
ags.Points.Add(new NAdvancedGradientPoint(Color.White, 50, 50, 0, 60, AGPointShape.Circle));
radialGauge.BackgroundFillStyle = ags;
NGaugeAxis axis = (NGaugeAxis)radialGauge.Axes[0];
NStandardScaleConfigurator scale = (NStandardScaleConfigurator)axis.ScaleConfigurator;
scale.SetPredefinedScaleStyle(PredefinedScaleStyle.Scientific);
NRangeIndicator rangeIndicator1 = new NRangeIndicator();
rangeIndicator1.OriginMode = OriginMode.ScaleMin;
rangeIndicator1.Value = 20;
rangeIndicator1.BeginWidth = new NLength(-20);
rangeIndicator1.EndWidth = new NLength(-10);
rangeIndicator1.FillStyle = new NColorFillStyle(Color.Red);
rangeIndicator1.StrokeStyle = new NStrokeStyle(Color.DarkRed);
rangeIndicator1.OffsetFromScale = new NLength(-10);
radialGauge.Indicators.Add(rangeIndicator1);
NRangeIndicator rangeIndicator2 = new NRangeIndicator();
rangeIndicator2.OriginMode = OriginMode.ScaleMax;
rangeIndicator2.Value = 80;
rangeIndicator2.BeginWidth = new NLength(-10);
rangeIndicator2.EndWidth = new NLength(-20);
rangeIndicator2.FillStyle = new NColorFillStyle(Color.Blue);
rangeIndicator1.StrokeStyle = new NStrokeStyle(Color.DarkBlue);
rangeIndicator2.OffsetFromScale = new NLength(-10);
radialGauge.Indicators.Add(rangeIndicator2);
NNeedleValueIndicator needleIndicator = new NNeedleValueIndicator();
needleIndicator.Value = 66;
needleIndicator.OffsetFromScale = new NLength(-2);
needleIndicator.Shape.FillStyle = new NColorFillStyle(Color.Red);
radialGauge.Indicators.Add(needleIndicator);
Visual Basic
Copy Code
Dim radialGauge As NRadialGaugePanel = New NRadialGaugePanel()
nChartControl1.Panels.Add(radialGauge)

radialGauge.ContentAlignment = ContentAlignment.BottomRight
radialGauge.Size = New NSizeL(New NLength(100, NRelativeUnit.ParentPercentage), New NLength(100, NRelativeUnit.ParentPercentage))
radialGauge.Location = New NPointL(New NLength(0), New NLength(0))
radialGauge.SweepAngle = 270
radialGauge.PaintEffect = New NGlassEffectStyle()
radialGauge.BorderStyle = New NEdgeBorderStyle(BorderShape.Auto)
Dim ags As NAdvancedGradientFillStyle = New NAdvancedGradientFillStyle()
ags.BackgroundColor = Color.Black
ags.Points.Add(New NAdvancedGradientPoint(Color.LightGray, 50, 50, 0, 100, AGPointShape.Circle))
ags.Points.Add(New NAdvancedGradientPoint(Color.White, 50, 50, 0, 60, AGPointShape.Circle))
radialGauge.BackgroundFillStyle = ags
Dim axis As NGaugeAxis = CType(radialGauge.Axes(0), NGaugeAxis)
Dim scale As NStandardScaleConfigurator = CType(axis.ScaleConfigurator, NStandardScaleConfigurator)
scale.SetPredefinedScaleStyle(PredefinedScaleStyle.Scientific)
Dim rangeIndicator1 As NRangeIndicator = New NRangeIndicator()
rangeIndicator1.OriginMode = OriginMode.ScaleMin
rangeIndicator1.Value = 20
rangeIndicator1.BeginWidth = New NLength(-20)
rangeIndicator1.EndWidth = New NLength(-10)
rangeIndicator1.FillStyle = New NColorFillStyle(Color.Red)
rangeIndicator1.StrokeStyle = New NStrokeStyle(Color.DarkRed)
rangeIndicator1.OffsetFromScale = New NLength(-10)
radialGauge.Indicators.Add(rangeIndicator1)
Dim rangeIndicator2 As NRangeIndicator = New NRangeIndicator()
rangeIndicator2.OriginMode = OriginMode.ScaleMax
rangeIndicator2.Value = 80
rangeIndicator2.BeginWidth = New NLength(-10)
rangeIndicator2.EndWidth = New NLength(-20)
rangeIndicator2.FillStyle = New NColorFillStyle(Color.Blue)
rangeIndicator1.StrokeStyle = New NStrokeStyle(Color.DarkBlue)
rangeIndicator2.OffsetFromScale = New NLength(-10)
radialGauge.Indicators.Add(rangeIndicator2)

Dim needleIndicator As NNeedleValueIndicator = New NNeedleValueIndicator()
needleIndicator.Value = 66
needleIndicator.OffsetFromScale = New NLength(-2)
needleIndicator.Shape.FillStyle = New NColorFillStyle(Color.Red)
radialGauge.Indicators.Add(needleIndicator)

This code will result in the following gauge configuration:

 Related Examples

Windows forms: Gauge Gallery\Gauges\Indicators

Web forms: Gauge Gallery\Gauges\Indicators

See Also