MCPcopy
hub / github.com/chartjs/Chart.js / getIntersectItems

Function getIntersectItems

src/core/core.interaction.js:114–132  ·  view source on GitHub ↗

* Helper function to get the items that intersect the event position * @param {Chart} chart - the chart * @param {Point} position - the point to be nearest to, in relative coordinates * @param {string} axis - the axis mode. x|y|xy|r * @param {boolean} [useFinalPosition] - use the element's anima

(chart, position, axis, useFinalPosition, includeInvisible)

Source from the content-addressed store, hash-verified

112 * @return {InteractionItem[]} the nearest items
113 */
114function getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) {
115 const items = [];
116
117 if (!includeInvisible && !chart.isPointInArea(position)) {
118 return items;
119 }
120
121 const evaluationFunc = function(element, datasetIndex, index) {
122 if (!includeInvisible && !_isPointInArea(element, chart.chartArea, 0)) {
123 return;
124 }
125 if (element.inRange(position.x, position.y, useFinalPosition)) {
126 items.push({element, datasetIndex, index});
127 }
128 };
129
130 evaluateInteractionItems(chart, axis, position, evaluationFunc, true);
131 return items;
132}
133
134/**
135 * Helper function to get the items nearest to the event position for a radial chart

Callers 3

indexFunction · 0.85
datasetFunction · 0.85
pointFunction · 0.85

Calls 2

evaluateInteractionItemsFunction · 0.85
isPointInAreaMethod · 0.80

Tested by

no test coverage detected