Nevron .NET Vision Documentation
Data Point Drag Tool

The data point dragging feature of the control is represented by the NDataPointDragTool class. When an object of this type is present in the Tools collection it will work with the current Selection to enable data point dragging.

To illustrate this lets take a look at the following code showing how to create a XY scatter point chart and enable the data point dragging feature allowing the user to move data points with the mouse:

Copy Code
NChart chart = chartControl.Charts[0];
NLinearScaleConfigurator linearConfigurator = new NLinearScaleConfigurator();
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearConfigurator;

NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point);
point.UseXValues = true;

Random random = new Random();

for (int i = 0; i < 10; i++)

chartControl.Controller.Tools.Add(new NSelectorTool());
chartControl.Controller.Tools.Add(new NDataPointDragTool());
Visual Basic
Copy Code
Dim chart As NChart = chartControl.Charts(0)
Dim linearConfigurator As NLinearScaleConfigurator = New NLinearScaleConfigurator
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearConfigurator

Dim point As NPointSeries = chart.Series.Add(SeriesType.Point)
point.UseXValues = True

Dim random As New Random

For i As Integer = 0 To 9
Next i

chartControl.Controller.Tools.Add(New NSelectorTool)
chartControl.Controller.Tools.Add(New NDataPointDragTool)

Now when the user presses the left mouse button over a data point and drags the mouse the data point X, Y values will change accordingly.

Controlling Horizontal and Vertical Dragging

There are cases when you may want to disable the dragging in the horizontal or vertical direction. You can easily achieve this by turning off the AllowHorizontalDragging or AllowVerticalDragging properties of the NDataPointDragTool. The following code disables dragging in the horizontal direction:

Copy Code
dataPointDragTool.AllowHorizontalDragging = false;
Visual Basic
Copy Code
dataPointDragTool.AllowHorizontalDragging = False
Modifying the Keyboard Shortcuts
The NDataPointDragTool allows the user to change the data point value using the keyboard navigation keys. For example when the user selects a data point he/she can move it by pressing the Ctrl key plus any of the arrow keys. The shortcuts to move the data point Up, Down, Left and Right are controlled by the DragUpShortcut, DragDownShortcut, DragLeftShortcut, and DragRightShortcut respectively. You can also control the the horizontal and vertical step by touching the HorizontalStep and VerticalStep properties.
See Also



©2019. Nevron Software LLC.

Send Feedback