Chart for .NET / User's Guide / Interactivity / Drag Tools / Range Selection Move Resize Tool

Range Selection Move Resize Tool

The range selection move resize drag tool allows the user to interactive drag and resize a range selection object (NRangeSelection). The following code shows how to create and configure a range selection move resize tool:

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 NCartesianChart = CType(NChartControl1.Charts(0), NCartesianChart)
Dim rangeSelection As New NRangeSelection
rangeSelection.AllowHorizontalResize = True
rangeSelection.AllowVerticalResize = True
rangeSelection.ShowGrippers = True
rangeSelection.Visible = True
rangeSelection.HorizontalAxisRange = New NRange1DD(10, 15)
rangeSelection.VerticalAxisRange = New NRange1DD(10, 15)
chart.RangeSelections.Add(rangeSelection)
Dim point As New NPointSeries
point.UseXValues = True
point.Values.Add(10)
point.XValues.Add(10)
point.Values.Add(20)
point.XValues.Add(20)
chart.Series.Add(Point)
NChartControl1.Controller.Tools.Add(New NRangeSelectionMoveResizeTool())

Now the user can move and resize the range selection.