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

Function getNearestItems

src/core/core.interaction.ts:273–288  ·  view source on GitHub ↗

* Helper function to get the items nearest to the event position considering all visible items in the chart * @param chart - the chart to look at elements from * @param position - the point to be nearest to, in relative coordinates * @param axis - the axes along which to measure distance * @para

(
  chart: Chart,
  position: Point,
  axis: string,
  intersect?: boolean,
  useFinalPosition?: boolean,
  includeInvisible?: boolean
)

Source from the content-addressed store, hash-verified

271 * @return the nearest items
272 */
273function getNearestItems(
274 chart: Chart,
275 position: Point,
276 axis: string,
277 intersect?: boolean,
278 useFinalPosition?: boolean,
279 includeInvisible?: boolean
280): InteractionItem[] {
281 if (!includeInvisible && !chart.isPointInArea(position)) {
282 return [];
283 }
284
285 return axis === 'r' && !intersect
286 ? getNearestRadialItems(chart, position, axis, useFinalPosition)
287 : getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible);
288}
289
290/**
291 * Helper function to get the items matching along the given X or Y axis

Callers 3

indexFunction · 0.85
datasetFunction · 0.85
nearestFunction · 0.85

Calls 3

getNearestRadialItemsFunction · 0.85
getNearestCartesianItemsFunction · 0.85
isPointInAreaMethod · 0.80

Tested by

no test coverage detected