The Hit-Test API is a set of virtual methods defined on
ISCIRenderableSeries such as:
This API is used by the
SCISeriesSelectionModifier to transform touch on screen into data-points, and determine if touch event occurs over a point or over a series.
To call the Hit-Test method, use the following code:
NOTE: You must transform any touch events into the coordinate space of the main chart area. Without this, all hit-test results will be inaccurate. You can learn more about it in the Axis APIs - Convert Pixel to Data coordinates article.
The Hit-Test Results
SCIHitTestInfo which is used for Hit-Test contains some useful properties to determine what point was touched.
||The coordinates of a point, that is used for Hit-Test.|
||The Hit-Test radius which was used for searching of nearest data point.|
||If data point that was hit contains the index of the point in
||If data point that was hit contains the index of hit test point in associated
||Boolean flag which tells whether or not
||Boolean flag which tells if
The UseInterpolation flag increases the accuracy of the Hit-Test at the expense of performance. You can modify its value via the
SCITooltipModifierBase.useInterpolation property, which is available for all the inheritors such as
SCITooltipModifier, for example.
SCIFastLineRenderableSeries and it’s possible interpolation cases:
useInterpolation = NO- hit-test will return
SCIHitTestInfo.isHit= YES - only if the input mouse-point is over a data-point.
useInterpolation = YES- hit-test will return
SCIHitTestInfo.isHit= YES - if the input touch event is over the line.
This is useful say if you wanted to show a tooltip only on data-points (
useInterpolation = NO) vs. anywhere on the line (
For other series types, such as
useInterpolation = YES will result in an
isHit = YES when touch is over the series as opposed to over the data-points.
NOTE: The interpolation is linear and linear only at the time of writing, it is not suitable for use by Logarithmic Axis.
Examples of Use of the Hit Test API
Our own source code uses the Hit-Test API to perform hit-testing when showing tooltips at a touch location. We also have published some examples of use.
iOS Chart Hit Test API Example
This example shows you how to use the Hit-Test API on tap, and reports hit results to a popup.