* Helper function to select candidate elements for interaction * @param {Chart} chart - the chart * @param {string} axis - the axis mode. x|y|xy|r * @param {Point} position - the point to be nearest to, in relative coordinates * @param {function} handler - the callback to execute for each visibl
(chart, axis, position, handler, intersect)
| 72 | * @param {boolean} [intersect] - consider intersecting items |
| 73 | */ |
| 74 | function evaluateInteractionItems(chart, axis, position, handler, intersect) { |
| 75 | const metasets = chart.getSortedVisibleDatasetMetas(); |
| 76 | const value = position[axis]; |
| 77 | for (let i = 0, ilen = metasets.length; i < ilen; ++i) { |
| 78 | const {index, data} = metasets[i]; |
| 79 | const {lo, hi} = binarySearch(metasets[i], axis, value, intersect); |
| 80 | for (let j = lo; j <= hi; ++j) { |
| 81 | const element = data[j]; |
| 82 | if (!element.skip) { |
| 83 | handler(element, index, j); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Get a distance metric function for two points based on the |
no test coverage detected