Chart for .NET / Getting Started / Integrating ThinWeb Chart / Tools / Indicator Drag Tool
In This Topic
    Indicator Drag Tool
    In This Topic

    The indicator drag tool allows the user to change the value of gauge indicators interactively by pressing the mouse over the indicator and then dragging it.

    In order to use the indicator drag tool you must create an instance of the NIndicatorDragTool object and add it to the control Tools collection:

    C#
    Copy Code

    NThinChartControl1.Controller.Tools.Add(new NIndicatorDragTool());

    Visual Basic
    Copy Code

    NThinChartControl1.Controller.Tools.Add(New NIndicatorDragTool())

    Sometimes the gauge can contain many indicators and you may want to mark some of them as non draggable. This is achieved by setting the AllowDragging property of the respective indicator to false.

    C#
    Copy Code

    someIndicator.AllowDragging = false;

    Visual Basic
    Copy Code

    someIndicator.AllowDragging = False

    Similarly to the other dragging tools - the indicator drag tool can invoke a callback when the value of the currently dragged indicator has changed. The following code snippet shows how to implement a simple gauge with a draggable indicator:

    C#
    Copy Code

    public partial class _Default : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!NThinChartControl1.Initialized)

    {

    NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false;

    NThinChartControl1.Panels.Clear();

    // set a chart title

    NLabel header = new NLabel();

    NThinChartControl1.Panels.Add(header);

    // create the radial gauge

    NRadialGaugePanel radialGauge = new NRadialGaugePanel();

    NThinChartControl1.Panels.Add(radialGauge);

    // add needle

    NNeedleValueIndicator needleIndicator = new NNeedleValueIndicator();

    radialGauge.Indicators.Add(needleIndicator);

    header.Text = needleIndicator.Value.ToString();

    // add drag tool

    NIndicatorDragTool indicatorDragTool = new NIndicatorDragTool();

    indicatorDragTool.IndicatorDragCallback = new IndicatorDragCallback();

    NThinChartControl1.Controller.Tools.Add(indicatorDragTool);

    }

    }

    [Serializable]

    class IndicatorDragCallback : INIndicatorDragCallback

    {

    #region INIndicatorDragCallback Members

    public void OnIndicatorValueChanged(NThinChartControl control, NGaugePanel gauge, NIndicator indicator, double oldValue, double newValue)

    {

    control.Labels[0].Text = indicator.Value.ToString();

    }

    #endregion

    }

    }

     Related Examples

    Web Forms\ThinWeb\Indicator Drag Tool
    Web Forms\ThinWeb\Custom Commands

    Mvc\ThinWeb\Indicator Drag Tool