Chart for .NET / User's Guide / Gauges / Indicators / Knob Indicator
In This Topic
    Knob Indicator
    In This Topic

    Knob indicators are visualized by radial gauges and extend the functionality of the NValueIndicator class. Therefore knob indicators have the same behavior as the NMarkerValueIndicator and the NNeedleValueIndicator indicators, with extensions specific to the the knob visualization.

     Creating a Knob Indicator

    In order to create a knob indicator you must first create an instance of the NKnobIndicator class and then add it to the Indicators collection of the radial gauge. The following code snippet creates a simple radial gauge with a knob:

    C#
    Copy Code

    nChartControl1.Panels.Clear();

    // create a radial gauge
    NRadialGaugePanel radialGauge = new NRadialGaugePanel();
    nChartControl1.Panels.Add(radialGauge);
    radialGauge.CapStyle.Visible =
    false;
    radialGauge.BeginAngle = -225;
    radialGauge.SweepAngle = 270;

    // modify the scale
    NGaugeAxis axis = (NGaugeAxis)radialGauge.Axes[0];
    NLinearScaleConfigurator scale = axis.ScaleConfigurator as NLinearScaleConfigurator;
    scale.SetPredefinedScaleStyle(
    PredefinedScaleStyle.Presentation);

    // add knob
    NKnobIndicator knobIndicator = new NKnobIndicator();
    knobIndicator.OffsetFromScale =
    new NLength(-2);
    radialGauge.Indicators.Add(knobIndicator);

    Visual Basic
    Copy Code

    NChartControl1.Panels.Clear()

    ' create a radial gauge
    Dim radialGauge As New NRadialGaugePanel
    NChartControl1.Panels.Add(radialGauge)
    radialGauge.CapStyle.Visible =
    False
    radialGauge.BeginAngle = -225
    radialGauge.SweepAngle = 270

    ' modify the scale
    Dim axis As NGaugeAxis = CType(radialGauge.Axes(0), NGaugeAxis)
    Dim
    scale As NLinearScaleConfigurator = CType
    axis.ScaleConfigurator, NLinearScaleConfigurator)
    Scale.SetPredefinedScaleStyle(PredefinedScaleStyle.Presentation)

    ' add knob
    Dim knobIndicator As New NKnobIndicator()
    knobIndicator.OffsetFromScale =
    New NLength(-2)
    radialGauge.Indicators.Add(knobIndicator)

     

     Knob Elements

    Each knob element consists of several parts as shown the following picture:

    The inner and outer rim style are controlled through the InnerRimStyle and OuterRimStyle properties of the NKnobIndicator respectively. For a detailed description of the options avialable for the rim style check the "Rim Style" section below. The knob marker position is determined by the Value property of the indicator (as with all indicators that extend the NValueIndicator class) and its shape is specified as a smart shape

     

     Rim Style

    Both the inner and the outer rim styles of the knob are controlled through an instance of the NCircularRimStyle class. The rim style has several properties allowing you to customize its pattern.

    Rim Pattern

    You can change the rim pattern with the help of the Pattern property of the rim style. On the picture above the outer rim style uses RoundHandle rim pattern and the inner rim uses Circle respectively. The following table lists the available pattern options:

    Pattern Description
    Bolt The appearance of the rim resembles a bolt.
    Circle The rim is circular. On the picture above the inner rim style uses this pattern.
    EdgeHandle The appearance of the rim resembles a handle with "edges".
    EdgeHandleSmall Same as edge handle except the dips between edges are smaller.
    RoundHandle The appearance of the rim resembles a handle with round edges. On the picture above the outer rim style uses this pattern.
    RoundHandleSmall Same as RoundHandle except the the dips between the edges are smaller.

    Repeat Count 

    For all rim patterns except circle you can also control the PatternRepeatCount property allowing you specify how many times the pattern will be repeated around the knob edge. On the picture above the outer rim uses a repeat count of 6.

    Radius Offset

    The Offset property allows you to configure the distance of the rim pattern from the rim of the knob.

    The following code snippet shows how to modify these properties:

    C#
    Copy Code

    // create the knob
    NKnobIndicator knobIndicator = new NKnobIndicator();

    // offset the knob from the scale
    knobIndicator.OffsetFromScale = new NLength(-2);

    // configure the outer rim style
    knobIndicator.OuterRimStyle.Pattern = CircularRimPattern.RoundHandleSmall;
    knobIndicator.OuterRimStyle.PatternRepeatCount = 8;
    knobIndicator.OuterRimStyle.Offset =
    new NLength(2);

    Visual Basic
    Copy Code

    ' create the knob
    Dim knobIndicator As New NKnobIndicator()

    ' offset the knob from the scale
    knobIndicator.OffsetFromScale = New NLength(-2)

    ' configure the outer rim style
    knobIndicator.OuterRimStyle.Pattern = CircularRimPattern.RoundHandleSmall
    knobIndicator.OuterRimStyle.PatternRepeatCount = 8
    knobIndicator.OuterRimStyle.Offset =
    New NLength(2)

     Related Examples

    Windows forms: Gauge Gallery\Gauges\Indicators\Knob Indicator

    Web forms: Gauge Gallery\Gauges\Indicators\Knob Indicator