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

In This Topic
    Needle Indicator
    In This Topic

    Needle indicators are visualized by radial gauges and are represented by smart shapes with two anchor points – the first anchor point is the radial gauge center and the second one is the scaled value of the needle indicator.

     Needle Value

    The needle Value property defines how the needle is oriented in the radial gauge. The following code will change the value of a newly created needle indicator:

    C#
    Copy Code
    nChartControl1.Panels.Clear();
    NRadialGaugePanel radialGauge = new NRadialGaugePanel();
    nChartControl1.Panels.Add(radialGauge); 
    NNeedleValueIndicator needle = new NNeedleValueIndicator();
    needle.Value = 10; 
    radialGauge.Indicators.Add(needle);
    nChartControl1.Refresh();
    
    Visual Basic
    Copy Code
    NChartControl1.Panels.Clear() 
    Dim radialGauge As New NRadialGaugePanel
    NChartControl1.Panels.Add(radialGauge)
    Dim needle As New NNeedleValueIndicator
    needle.Value = 10
    radialGauge.Indicators.Add(needle)
    NChartControl1.Refresh()
    
     Needle Shape

    The needle shape is controlled through the needle Shape property accepting 1D smart shape definitions. Similar to the way you modify the marker indicator shapes if you want to modify the needle appearance you need to change its shape. One way to do this is to use the built-in N1DSmartShapeFactory class:

    C#
    Copy Code
    nChartControl1.Panels.Clear();
    NRadialGaugePanel radialGauge = new NRadialGaugePanel();
    nChartControl1.Panels.Add(radialGauge);
    NNeedleValueIndicator needle = new NNeedleValueIndicator();
    needle.Value = 10; 
    N1DSmartShapeFactory factory = new N1DSmartShapeFactory(new NColorFillStyle(Color.Red), new NStrokeStyle(Color.DarkRed), new NShadowStyle());
    needle.Shape = factory.CreateShape(SmartShape1D.Arrow1);
    
    radialGauge.Indicators.Add(needle); 
    nChartControl1.Refresh();
    
    Visual Basic
    Copy Code
    NChartControl1.Panels.Clear()
    Dim radialGauge As New NRadialGaugePanel
    NChartControl1.Panels.Add(radialGauge)
    Dim needle As New NNeedleValueIndicator
    needle.Value = 10
    Dim factory As New N1DSmartShapeFactory(New NColorFillStyle(Color.Red), New NStrokeStyle(Color.DarkRed), New NShadowStyle)
    needle.Shape = factory.CreateShape(SmartShape1D.Arrow1) 
    radialGauge.Indicators.Add(needle) 
    NChartControl1.Refresh()
    
     Needle Appearance

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

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

    The width of the needle is controlled through the Width property of the NNeedleValueIndicator class:

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

    Windows forms: Gauge Gallery\Gauges\Indicators

    Web forms: Gauge Gallery\Gauges\Indicators

     

    See Also

    NMarkerValueIndicator | NSmartShape | N2DSmartShapeFactory | Smart Shapes

    See Also