Nevron .NET Vision

In This Topic
    Hit Testing Axis Elements
    In This Topic

    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:

    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
    // this is some other axis part
    Visual Basic
    Copy Code

    Dim linearScale = CType(chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator, NLinearScaleConfigurator)

    linearScale.Title.Text = "Y Axis Title"
    linearScale.Title.PartId = 1


    ' later in hit test

    Dim result As NHitTestResult = NChartControl1.HitTest(New Point(e.X, e.Y))

    If result.ChartElement = ChartElement.Axis Then
    If result.AxisScalePartId = 1 Then
    ' this is an axis title
    ' this is some other axis part
    End If
    End If

    Note that the code first assigns some value to the PartId and uses this value to distringuish this part in the axis.

     Related Examples
    Type your Collapsible Section text here.
    See Also