Hi Alexandr,
The following code snippet shows how to find the closest axis tick value (provided that the step is fixed):
private void Form1_Load(object sender, EventArgs e)
{
NChart chart = nChartControl1.Charts[0];
NBarSeries bar = new NBarSeries();
bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(30);
chart.Series.Add(bar);
NLinearScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
scaleY.MajorTickMode = MajorTickMode.CustomStep;
scaleY.CustomStep = 5;
nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown);
}
void nChartControl1_MouseDown(object sender, MouseEventArgs e)
{
NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);
if (result.Axis != null && result.Axis.AxisId == (int)StandardAxis.PrimaryY)
{
NViewToScale1DTransformation viewToScale = new NViewToScale1DTransformation(nChartControl1.View.Context, nChartControl1.Charts[0], (int)StandardAxis.PrimaryY, (int)StandardAxis.PrimaryX);
double scaleValue = 0;
if (viewToScale.Transform(new NPointF(e.X, e.Y), ref scaleValue))
{
double tickValue = (int)Math.Round(scaleValue / 5) * 5;
MessageBox.Show("Closest tick value[" + tickValue.ToString() + "]");
}
}
}
Hope this helps - let us know if you meet any problems or have any questions.
Best Regards,
Nevron Support Team