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

Marker Indicator

In order to add a marker indicator to a gauge panel you need to create an instance of the NMarkerValueIndicator and then add it to the Indicators collection of the panel.

 Marker Value

The marker Value property defines how the marker is positioned along the axis. The following code will create two marker indicators positioned at values 10 and 90:

C#
Copy Code
nChartControl1.Panels.Clear();
NRadialGaugePanel radialGauge = new NRadialGaugePanel();
nChartControl1.Panels.Add(radialGauge);

radialGauge.Indicators.Add(new NMarkerValueIndicator(10));
radialGauge.Indicators.Add(new NMarkerValueIndicator(90));
nChartControl1.Refresh();
Visual Basic
Copy Code
NChartControl1.Panels.Clear()
Dim radialGauge As New NRadialGaugePanel 
NChartControl1.Panels.Add(radialGauge)
radialGauge.Indicators.Add(New NMarkerValueIndicator(10))
radialGauge.Indicators.Add(New NMarkerValueIndicator(90)) 
NChartControl1.Refresh()
 Marker Shape

The marker shape and appearance are controlled through the Shape property exposed by the NMarkerValueIndicator class. This property accepts a 2D Smart Shape definition that you can create either standalone or use some of the predefined 2D smart shapes exposed from the N2DSmartShapeFactory class. By default the maker will use a triangular smart shape definition, but you can change this by simply creating a new smart shape and assigning it to the Shape property of the indicator.

The following code will change the marker shape to bar:

C#
Copy Code
nChartControl1.Panels.Clear(); 
NRadialGaugePanel radialGauge = new NRadialGaugePanel();
nChartControl1.Panels.Add(radialGauge); 
NMarkerValueIndicator marker = new NMarkerValueIndicator();
marker.Value = 10;

N2DSmartShapeFactory factory = new N2DSmartShapeFactory(new NColorFillStyle(Color.Red), new NStrokeStyle(Color.DarkRed), new NShadowStyle());
NSmartShape smartShape = factory.CreateShape(SmartShape2D.Bar);
marker.Shape = smartShape;
radialGauge.Indicators.Add(marker); 
nChartControl1.Refresh();
Visual Basic
Copy Code
NChartControl1.Panels.Clear() 
Dim radialGauge As New NRadialGaugePanel
NChartControl1.Panels.Add(radialGauge)
Dim marker As New NMarkerValueIndicator
marker.Value = 10
Dim factory As New N2DSmartShapeFactory(New NColorFillStyle(Color.Red), New NStrokeStyle(Color.DarkRed), New NShadowStyle)
Dim smartShape As NSmartShape = factory.CreateShape(SmartShape2D.Bar)
marker.Shape = smartShape 
NChartControl1.Refresh()
 Marker Appearance

Marker appearance is controlled through the smart shape FillStyle, StrokeStyle and ShadowStyle properties. The following code snippet will change the marker filling and stroke to dark green:

C#
Copy Code
nChartControl1.Panels.Clear(); 
NRadialGaugePanel radialGauge = new NRadialGaugePanel();
nChartControl1.Panels.Add(radialGauge);
NMarkerValueIndicator marker = new NMarkerValueIndicator();
marker.Value = 10;
marker.Shape.FillStyle = new NColorFillStyle(Color.DarkGreen);
marker.Shape.StrokeStyle = new NStrokeStyle(Color.DarkGreen); 
radialGauge.Indicators.Add(marker);
nChartControl1.Refresh();
Visual Basic
Copy Code
NChartControl1.Panels.Clear() 
Dim radialGauge As New NRadialGaugePanel
NChartControl1.Panels.Add(radialGauge) 
Dim marker As New NMarkerValueIndicator
marker.Value = 10
marker.Shape.FillStyle = New NColorFillStyle(Color.DarkGreen)
marker.Shape.StrokeStyle = New NStrokeStyle(Color.DarkGreen) 
radialGauge.Indicators.Add(marker)
NChartControl1.Refresh()
 Marker Size

The marker size is controlled by the Width and Height properties exposed by the NMarkerValueIndicator class. The following code will make the value indicator bigger:

C#
Copy Code
nChartControl1.Panels.Clear(); 
NRadialGaugePanel radialGauge = new NRadialGaugePanel();
nChartControl1.Panels.Add(radialGauge); 
NMarkerValueIndicator marker = new NMarkerValueIndicator();
marker.Value = 10;
marker.Width = new NLength(20);
marker.Height = new NLength(20);
radialGauge.Indicators.Add(marker); 
nChartControl1.Refresh();
Visual Basic
Copy Code
NChartControl1.Panels.Clear()
Dim radialGauge As New NRadialGaugePanel
NChartControl1.Panels.Add(radialGauge)
Dim marker As New NMarkerValueIndicator
marker.Value = 10
marker.Width = New NLength(20)
marker.Height = New NLength(20)
radialGauge.Indicators.Add(marker) 
NChartControl1.Refresh()
 Related Examples

Windows forms: Gauge Gallery\Gauges\Indicators

Web forms: Gauge Gallery\Gauges\Indicators

See Also