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

Function _computeSegments

src/helpers/helpers.segment.js:238–257  ·  view source on GitHub ↗
(line, segmentOptions)

Source from the content-addressed store, hash-verified

236 * @private
237 */
238export function _computeSegments(line, segmentOptions) {
239 const points = line.points;
240 const spanGaps = line.options.spanGaps;
241 const count = points.length;
242
243 if (!count) {
244 return [];
245 }
246
247 const loop = !!line._loop;
248 const {start, end} = findStartAndEnd(points, count, loop, spanGaps);
249
250 if (spanGaps === true) {
251 return splitByStyles(line, [{start, end, loop}], points, segmentOptions);
252 }
253
254 const max = end < start ? end + count : end;
255 const completeLoop = !!line._fullLoop && start === 0 && end === count - 1;
256 return splitByStyles(line, solidSegments(points, start, max, completeLoop), points, segmentOptions);
257}
258
259/**
260 * @param {Segment[]} segments

Callers 1

segmentsMethod · 0.90

Calls 3

findStartAndEndFunction · 0.85
splitByStylesFunction · 0.85
solidSegmentsFunction · 0.85

Tested by

no test coverage detected