* Helper function to get the items matching along the given X or Y axis * @param {Chart} chart - the chart to look at elements from * @param {Point} position - the point to be nearest to, in relative coordinates * @param {string} axis - the axis to match * @param {boolean} [intersect] - if true,
(chart, position, axis, intersect, useFinalPosition)
| 226 | * @return {InteractionItem[]} the nearest items |
| 227 | */ |
| 228 | function getAxisItems(chart, position, axis, intersect, useFinalPosition) { |
| 229 | const items = []; |
| 230 | const rangeMethod = axis === 'x' ? 'inXRange' : 'inYRange'; |
| 231 | let intersectsItem = false; |
| 232 | |
| 233 | evaluateInteractionItems(chart, axis, position, (element, datasetIndex, index) => { |
| 234 | if (element[rangeMethod] && element[rangeMethod](position[axis], useFinalPosition)) { |
| 235 | items.push({element, datasetIndex, index}); |
| 236 | intersectsItem = intersectsItem || element.inRange(position.x, position.y, useFinalPosition); |
| 237 | } |
| 238 | }); |
| 239 | |
| 240 | // If we want to trigger on an intersect and we don't have any items |
| 241 | // that intersect the position, return nothing |
| 242 | if (intersect && !intersectsItem) { |
| 243 | return []; |
| 244 | } |
| 245 | return items; |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * Contains interaction related functions |
no test coverage detected
searching dependent graphs…