Skip to main content
All docs
V23.2

HeatmapControl.CalcHitInfo(Point) Method

Returns information about the visual element under the specified hit point.

Namespace: DevExpress.XtraCharts.Heatmap

Assembly: DevExpress.XtraCharts.v23.2.UI.dll

NuGet Package: DevExpress.Win.Charts

Declaration

public HeatmapHitInfo CalcHitInfo(
    Point point
)

Parameters

Name Type Description
point Point

Specifies the hit point relative to the control’s upper-left corner.

Returns

Type Description
HeatmapHitInfo

Contains information about the visual element under the specified hit point.

Remarks

The following example shows how to determine what a heatmap element is in a test point, and collect information related to this element.

A heatmap axis is hit-tested.

Call the HeatmapControl.CalcHitInfo method to obtain information about a specific point within the Heatmap Control. This method returns a HeatmapHitInfo object that contains information related to heatmap elements positioned in the test point.

using DevExpress.Utils;
using DevExpress.XtraCharts;
using DevExpress.XtraCharts.Heatmap;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HeatmapMatrixAdapterSample {
    public partial class Form1 : Form {
        HeatmapControl heatmap;
        ToolTipController toolTipController = new ToolTipController();
        public Form1() {
            InitializeComponent();
            //...
            heatmap.MouseMove += HeatmapMouseMove;
            heatmap.MouseLeave += HeatmapMouseLeave;
        }

        private void HeatmapMouseMove(object sender, MouseEventArgs e) {
            HeatmapHitInfo hitInfo = heatmap.CalcHitInfo(e.Location);
            StringBuilder builder = new StringBuilder();
            if (hitInfo.InAxis) {
                builder.AppendLine($"In axis: {hitInfo.Axis.Name}");
                if (hitInfo.AxisLabelItem != null)
                    builder.AppendLine($"  Label: {hitInfo.AxisLabelItem.Text}");
                if (hitInfo.AxisTitle != null)
                    builder.AppendLine($"  Axis title: {hitInfo.AxisTitle.Text}");
            }
            if (hitInfo.InCell)
                builder.AppendLine($" In cell: X ({hitInfo.Cell.XArgument}), Y ({hitInfo.Cell.YArgument})");
            if (hitInfo.InTitle)
                builder.AppendLine($" In title: {hitInfo.Title.Text}");
            if (hitInfo.InLegend)
                builder.AppendLine($" In legend");

            if (builder.Length > 0)
                toolTipController.ShowHint($"Hit-testing results:\n {builder}", heatmap.PointToScreen(e.Location));
            else
                toolTipController.HideHint();
        }
        private void HeatmapMouseLeave(object sender, System.EventArgs e) {
            toolTipController.HideHint();
        }
    }
}
See Also