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

Function getNearestRadialItems

src/core/core.interaction.js:142–156  ·  view source on GitHub ↗

* Helper function to get the items nearest to the event position for a radial chart * @param {Chart} chart - the chart to look at elements from * @param {Point} position - the point to be nearest to, in relative coordinates * @param {string} axis - the axes along which to measure distance * @par

(chart, position, axis, useFinalPosition)

Source from the content-addressed store, hash-verified

140 * @return {InteractionItem[]} the nearest items
141 */
142function getNearestRadialItems(chart, position, axis, useFinalPosition) {
143 let items = [];
144
145 function evaluationFunc(element, datasetIndex, index) {
146 const {startAngle, endAngle} = element.getProps(['startAngle', 'endAngle'], useFinalPosition);
147 const {angle} = getAngleFromPoint(element, {x: position.x, y: position.y});
148
149 if (_angleBetween(angle, startAngle, endAngle)) {
150 items.push({element, datasetIndex, index});
151 }
152 }
153
154 evaluateInteractionItems(chart, axis, position, evaluationFunc);
155 return items;
156}
157
158/**
159 * Helper function to get the items nearest to the event position for a cartesian chart

Callers 1

getNearestItemsFunction · 0.85

Calls 1

evaluateInteractionItemsFunction · 0.85

Tested by

no test coverage detected