* Helper function to select candidate elements for interaction * @param chart - the chart * @param axis - the axis mode. x|y|xy|r * @param position - the point to be nearest to, in relative coordinates * @param handler - the callback to execute for each visible item * @param [intersect] - consi
( chart: Chart, axis: string, position: Point, handler: (element: Element & VisualElement, datasetIndex: number, index: number) => void, intersect?: boolean )
| 95 | * @param [intersect] - consider intersecting items |
| 96 | */ |
| 97 | function evaluateInteractionItems( |
| 98 | chart: Chart, |
| 99 | axis: string, |
| 100 | position: Point, |
| 101 | handler: (element: Element & VisualElement, datasetIndex: number, index: number) => void, |
| 102 | intersect?: boolean |
| 103 | ): void { |
| 104 | const metasets = chart.getSortedVisibleDatasetMetas() as ChartMeta[]; |
| 105 | const value = position[axis]; |
| 106 | for (let i = 0, ilen = metasets.length; i < ilen; ++i) { |
| 107 | const {index, data} = metasets[i]; |
| 108 | const {lo, hi} = binarySearch(metasets[i], axis, value, intersect); |
| 109 | for (let j = lo; j <= hi; ++j) { |
| 110 | const element = data[j] as InteractionElement; |
| 111 | if (!element.skip) { |
| 112 | handler(element, index, j); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Get a distance metric function for two points based on the |
no test coverage detected