Chart for .NET / User's Guide / Interactivity / Drag Tools / Callout Drag Tool

In This Topic
    Callout Drag Tool
    In This Topic

    The callout drag tool is represented by the NCalloutDragTool class. When an object of this type is present in the Tools collection it will work with the current Selection to enable annotation dragging.

    The following code shows how to create an NCalloutDragTool

    C#
    Copy Code
    NChart chart = nChartControl1.Charts[0];
    NPointSeries point = new NPointSeries();
    point.Values.Add(10);
    point.Values.Add(20);
    chart.Series.Add(point);
    NRectangularCallout callout1 = new NRectangularCallout();
    callout1.UseAutomaticSize = true;
    callout1.Text = "Annotation 1";
    callout1.Orientation = 125;
    callout1.ArrowLength = new NLength(40, NGraphicsUnit.Point);
    callout1.Anchor = new NDataPointAnchor(point, 0, ContentAlignment.MiddleCenter, StringAlignment.Center);
    chart.ChildPanels.Add(callout1);
    NRectangularCallout callout2 = new NRectangularCallout();
    callout2.UseAutomaticSize = true;
    callout2.Text = "Annotation 2";
    callout1.Orientation = 45;
    callout2.ArrowLength = new NLength(40, NGraphicsUnit.Point);
    callout2.Anchor = new NDataPointAnchor(point, 1, ContentAlignment.MiddleCenter, StringAlignment.Center);
    chart.ChildPanels.Add(callout2);
    nChartControl1.Controller.Tools.Add(new NSelectorTool());
    nChartControl1.Controller.Tools.Add(new NCalloutDragTool());
    
    Visual Basic
    Copy Code
    Dim chart As NChart = NChartControl1.Charts(0)
    Dim point As New NPointSeries()
    point.Values.Add(10)
    point.Values.Add(20)
    chart.Series.Add(point)
    Dim callout1 As New NRectangularCallout()
    callout1.UseAutomaticSize = True
    callout1.Text = "Annotation 1"
    callout1.Orientation = 125
    callout1.ArrowLength = New NLength(40, NGraphicsUnit.Point)
    callout1.Anchor = New NDataPointAnchor(point, 0, ContentAlignment.MiddleCenter, StringAlignment.Center)
    chart.ChildPanels.Add(callout1)
    Dim callout2 As New NRectangularCallout
    callout2.UseAutomaticSize = True
    callout2.Text = "Annotation 2"
    callout1.Orientation = 45
    callout2.ArrowLength = New NLength(40, NGraphicsUnit.Point)
    callout2.Anchor = New NDataPointAnchor(point, 1, ContentAlignment.MiddleCenter, StringAlignment.Center)
    chart.ChildPanels.Add(callout2)
    NChartControl1.Controller.Tools.Add(New NSelectorTool())
    NChartControl1.Controller.Tools.Add(New NCalloutDragTool())
    

    Now when the user can drag the callouts.