HitTest(Point,Double,Boolean) Method
Performs a hit-test at the specific mouse point (X,Y coordinate on the parent SciChart.Charting.Visuals.SciChartSurface) using passed hitTestRadius, returning a SciChart.Charting.Visuals.RenderableSeries.HitTestInfo struct with the results
Syntax
public override HitTestInfo HitTest( Point rawPoint, double hitTestRadius, bool interpolate )
Parameters
- rawPoint
- The mouse point on the parent SciChart.Charting.Visuals.SciChartSurface
- hitTestRadius
- The radius in pixels to determine whether a mouse is over a data-point
- interpolate
- If true, use interpolation to perform a hit-test between data-points, or on the area if a
, or
Return Value
A SciChart.Charting.Visuals.RenderableSeries.HitTestInfo struct with the results
Example
Demonstrates how to use the Hit-Test API from a SciChartSurface.MouseLeftButtonUp event
// sciChartSurface.MouseLeftButtonUp += SciChartSurfaceMouseLeftButtonUp; private void SciChartSurfaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { // Perform the hit test relative to the GridLinesPanel Point mousePoint = e.GetPosition(sciChartSurface.GridLinesPanel as UIElement); double datapointRadius = 8; bool useInterpolation = false; HitTestInfo result = sciChartSurface.RenderableSeries[0].HitTest(mousePoint, datapointRadius, useInterpolation); // Output results string formattedString = string.Format( "{6}:\tMouse Coord: {0:0}, {1:0}\t\tNearest Datapoint Coord: {2:0.0}, {3:0.0}\tData Value: {4:0.0}, {5:0.0}", mousePoint.X, mousePoint.Y, result.HitTestPoint.X, result.HitTestPoint.Y, result.XValue, result.YValue, result.DataSeriesName); Console.WriteLine(formattedString); }
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also