MCPcopy Create free account
hub / github.com/chartjs/Chart.js / getIntersectItems

Function getIntersectItems

src/core/core.interaction.ts:143–172  ·  view source on GitHub ↗

* 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
)

Source from the content-addressed store, hash-verified

141 * @return the nearest items
142 */
143function 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

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