* Helper function to get the items that intersect the event position * @param chart - the chart * @param position - the point to be nearest to, in relative coordinates * @param axis - the axis mode. x|y|xy|r * @param [useFinalPosition] - use the element's animation target instead of current posi
( chart: Chart, position: Point, axis: string, useFinalPosition?: boolean, includeInvisible?: boolean )
| 141 | * @return the nearest items |
| 142 | */ |
| 143 | function getIntersectItems( |
| 144 | chart: Chart, |
| 145 | position: Point, |
| 146 | axis: string, |
| 147 | useFinalPosition?: boolean, |
| 148 | includeInvisible?: boolean |
| 149 | ): InteractionItem[] { |
| 150 | const items: InteractionItem[] = []; |
| 151 | |
| 152 | if (!includeInvisible && !chart.isPointInArea(position)) { |
| 153 | return items; |
| 154 | } |
| 155 | |
| 156 | const evaluationFunc = function(element: InteractionElement, datasetIndex: number, index: number) { |
| 157 | if (!element.inRange(position.x, position.y, useFinalPosition)) { |
| 158 | return; |
| 159 | } |
| 160 | if (!includeInvisible) { |
| 161 | const areaCenter = getAreaCenter(element, chart.chartArea, useFinalPosition); |
| 162 | const visible = areaCenter === undefined ? _isPointInArea(element, chart.chartArea, 0) : areaCenter !== null; |
| 163 | if (!visible) { |
| 164 | return; |
| 165 | } |
| 166 | } |
| 167 | items.push({element, datasetIndex, index}); |
| 168 | }; |
| 169 | |
| 170 | evaluateInteractionItems(chart, axis, position, evaluationFunc, true); |
| 171 | return items; |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Helper function to get the items nearest to the event position for a radial chart |
no test coverage detected