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

Function _pointsFromSegments

src/plugins/plugin.filler/filler.segment.js:65–82  ·  view source on GitHub ↗
(boundary, line)

Source from the content-addressed store, hash-verified

63}
64
65export function _pointsFromSegments(boundary, line) {
66 const {x = null, y = null} = boundary || {};
67 const linePoints = line.points;
68 const points = [];
69 line.segments.forEach(({start, end}) => {
70 end = _findSegmentEnd(start, end, linePoints);
71 const first = linePoints[start];
72 const last = linePoints[end];
73 if (y !== null) {
74 points.push({x: first.x, y});
75 points.push({x: last.x, y});
76 } else if (x !== null) {
77 points.push({x, y: first.y});
78 points.push({x, y: last.y});
79 }
80 });
81 return points;
82}
83
84export function _findSegmentEnd(start, end, points) {
85 for (;end > start; end--) {

Callers 1

_createBoundaryLineFunction · 0.90

Calls 1

_findSegmentEndFunction · 0.85

Tested by

no test coverage detected