Hi Kevin,
You can assign a part id to different axis elements if you want to distinguish on which one of them the user clicked - this is illustrated by the following example:
All Examples \ Interactivity \ Mouse Events \ Axes Hit Testing Scale Elements
The following code shows how to use this approach:
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);
nChartControl1.MouseClick += NChartControl1_MouseClick;
NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
scaleY.LabelStyle.PartId = 1;
}
private void NChartControl1_MouseClick(object sender, MouseEventArgs e)
{
NHitTestResult result = nChartControl1.HitTest(e.X, e.Y);
if (result.ChartElement == ChartElement.Axis)
{
// you clicked on the axis
if (result.AxisScalePartId == 1)
{
// you clicked on a label
NChart chart = nChartControl1.Charts[0];
NViewToScale1DTransformation viewToScale = new NViewToScale1DTransformation(null, chart, (int)StandardAxis.PrimaryY, (int)StandardAxis.PrimaryX);
double value = 0;
viewToScale.Transform(new Nevron.GraphicsCore.NPointF(e.X, e.Y), ref value);
MessageBox.Show("This is the label at value [" + value.ToString() + "]");
}
}
}
Note: The NViewToScale1DTransformation context constructor parameter is deprecated and will be removed in the next version as it is not used as part of the transformation.
We hope this helps - let us know if you have any questions.
Best Regards,
Nevron Support Team