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

Function findPoint

src/plugins/plugin.filler/filler.target.stack.js:87–109  ·  view source on GitHub ↗

* @param {LineElement} line * @param {PointElement} sourcePoint * @param {string} property * @returns {{point?: PointElement, first?: boolean, last?: boolean}}

(line, sourcePoint, property)

Source from the content-addressed store, hash-verified

85 * @returns {{point?: PointElement, first?: boolean, last?: boolean}}
86 */
87function findPoint(line, sourcePoint, property) {
88 const point = line.interpolate(sourcePoint, property);
89 if (!point) {
90 return {};
91 }
92
93 const pointValue = point[property];
94 const segments = line.segments;
95 const linePoints = line.points;
96 let first = false;
97 let last = false;
98 for (let i = 0; i < segments.length; i++) {
99 const segment = segments[i];
100 const firstValue = linePoints[segment.start][property];
101 const lastValue = linePoints[segment.end][property];
102 if (_isBetween(pointValue, firstValue, lastValue)) {
103 first = pointValue === firstValue;
104 last = pointValue === lastValue;
105 break;
106 }
107 }
108 return {first, last, point};
109}

Callers 1

addPointsBelowFunction · 0.85

Calls 2

_isBetweenFunction · 0.85
interpolateMethod · 0.65

Tested by

no test coverage detected