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

Function evaluateInteractionItems

src/core/core.interaction.ts:97–116  ·  view source on GitHub ↗

* Helper function to select candidate elements for interaction * @param chart - the chart * @param axis - the axis mode. x|y|xy|r * @param position - the point to be nearest to, in relative coordinates * @param handler - the callback to execute for each visible item * @param [intersect] - consi

(
  chart: Chart,
  axis: string,
  position: Point,
  handler: (element: Element & VisualElement, datasetIndex: number, index: number) => void,
  intersect?: boolean
)

Source from the content-addressed store, hash-verified

95 * @param [intersect] - consider intersecting items
96 */
97function evaluateInteractionItems(
98 chart: Chart,
99 axis: string,
100 position: Point,
101 handler: (element: Element & VisualElement, datasetIndex: number, index: number) => void,
102 intersect?: boolean
103): void {
104 const metasets = chart.getSortedVisibleDatasetMetas() as ChartMeta[];
105 const value = position[axis];
106 for (let i = 0, ilen = metasets.length; i < ilen; ++i) {
107 const {index, data} = metasets[i];
108 const {lo, hi} = binarySearch(metasets[i], axis, value, intersect);
109 for (let j = lo; j <= hi; ++j) {
110 const element = data[j] as InteractionElement;
111 if (!element.skip) {
112 handler(element, index, j);
113 }
114 }
115 }
116}
117
118/**
119 * Get a distance metric function for two points based on the

Callers 4

getIntersectItemsFunction · 0.85
getNearestRadialItemsFunction · 0.85
getNearestCartesianItemsFunction · 0.85
getAxisItemsFunction · 0.85

Calls 2

binarySearchFunction · 0.85

Tested by

no test coverage detected