Example #1
0
        // 7. Create a function for mouse move event handler.
        private void _chart_MouseMove(object sender, MouseEventArgs e)
        {
            // Call BeginUpdate for chart to disable rendering while mouse is moving
            // over the chart to improve performance.
            chart.BeginUpdate();

            // Set label visible when not hovered over by mouse.
            mouseAnnotation.Visible = false;

            // Check if any object has been found under the mouse.
            object obj = chart.GetActiveMouseOverObject();

            if (obj != null)
            {
                // Check if the active mouse over object is a PointLineSeries object.
                if (obj is PointLineSeries3D)
                {
                    PointLineSeries3D pointLineSeries3D = obj as PointLineSeries3D;

                    // Get the point last hit by mouse.
                    int           pointIndex = pointLineSeries3D.LastMouseHitTestIndex;
                    SeriesPoint3D point      = pointLineSeries3D.Points[pointIndex];

                    // Set annotation position to the moused over point.
                    mouseAnnotation.TargetAxisValues.SetValues(point.X, point.Y, point.Z);

                    // Set annotation text to display information about the moused over point.
                    mouseAnnotation.Text = "Series index: " + chart.View3D.PointLineSeries3D.IndexOf(pointLineSeries3D).ToString()
                                           + "\nPoint index: " + pointIndex.ToString()
                                           + "\nX=" + point.X.ToString("0.0") + " ; Y=" + point.Y.ToString("0.0") + " ; Z=" + point.Z.ToString("0.0");

                    // Set the annotation visible while mouse is hovering over the point.
                    mouseAnnotation.Visible = true;
                }
            }

            // Call EndUpdate to enable rendering again after handling mouse move event.
            chart.EndUpdate();
        }