Profile Picture

NDataPointDragTool with NAxisValueSnapper

Posted By cho seongho 4 Years Ago
Author
Message
cho seongho
Question Posted 4 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 15, Visits: 73
Hi.

I want to move datapoint aligned with MinorTick.
Can I use NDataPointDragTool with NAxisValueSnapper?

Nevron Support
Posted 4 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hi Cho,
The following code shows how to implement minor tick snapping while dragging a point a with the mouse:

class NCustomDataPointDragTool : NDataPointDragTool
{
protected override NDataPointXYZValue GetDataPointXYZValue(NVector3DF pointModel)
{
NDataPointXYZValue value = base.GetDataPointXYZValue(pointModel);

NChart chart = GetActiveChart();

value.X = chart.Axis(StandardAxis.PrimaryX).SnapValueToNearestMinorTick(value.X);

return value;
}
}

public Form1()
{
InitializeComponent();

NChart chart = nChartControl1.Charts[0];

NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator();
scaleX.MinorTickCount = 2;
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

NPointSeries point = new NPointSeries();
point.UseXValues = true;

point.Values.Add(10);
point.XValues.Add(10);

point.Values.Add(20);
point.XValues.Add(20);

point.Values.Add(30);
point.XValues.Add(30);

chart.Series.Add(point);

nChartControl1.Controller.Tools.Add(new NSelectorTool());

NCustomDataPointDragTool dragTool = new NCustomDataPointDragTool();
dragTool.DataPointChanged += DragTool_DataPointChanged;
nChartControl1.Controller.Tools.Add(dragTool);
}

Please note that for this to compile you need to download the latest version of .NET Vision as the GetDataPointXYZValue method was previously hidden (obfuscated).

Let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic