Skip to main content

How to: Determine whether an Axis Title is Being Hovered by the Mouse Pointer

This example demonstrates how you can determine whether an axis title is being hovered by the mouse pointer, and if so, display its type (AxisTitleX or AxisTitleY) in a tooltip.

using DevExpress.XtraCharts;
using System;
using System.Windows.Forms;

namespace AxisTitleHitTestSample {
    public partial class SampleForm : Form {
        public SampleForm() {
            InitializeComponent();
        }

        private void OnMouseMove(object sender, MouseEventArgs e) {
            ChartHitInfo hitInfo = chart.CalcHitInfo(e.X, e.Y);
            if (hitInfo.AxisTitle != null)
                tooltipController.ShowHint(
                    String.Format(
                        "The pointer is over the {0} object.", 
                        hitInfo.AxisTitle.GetType().ToString()
                    )
                );
            else
                tooltipController.HideHint();
        }
    }
}

The result is shown in the following image.

AxisTitleHitText

See Also