Hit testing of axis elements is achieved in a slightly different manner than with ordinary chart objects. The reason for this is that one element in the axis description may result in several visual elements - for example the major tick style in the axis scale configurator is applied to multiple major ticks on the axis. Therefore each style in the axis has a property called PartId, which allows you to assign a value that can later be retrieved from the hit test result object. The following code snippet shows how to use this property to distinguish between different scale elements:
C# |
Copy Code
|
---|---|
NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.Title.Text = "Y Axis Title"; linearScale.Title.PartId = 1; // later in hit test NHitTestResult result = nChartControl1.HitTest(new Point(e.X, e.Y)); if (result.ChartElement == ChartElement.Axis) { if (result.AxisScalePartId == 1) { // this is an axis title } else { // this is some other axis part } } |
Visual Basic |
Copy Code
|
---|---|
Dim linearScale = CType(chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator, NLinearScaleConfigurator)
' later in hit test |
Note that the code first assigns some value to the PartId and uses this value to distringuish this part in the axis.