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

Function sample

src/core/core.scale.js:23–33  ·  view source on GitHub ↗

* Returns a new array containing numItems from arr * @param {any[]} arr * @param {number} numItems

(arr, numItems)

Source from the content-addressed store, hash-verified

21 * @param {number} numItems
22 */
23function sample(arr, numItems) {
24 const result = [];
25 const increment = arr.length / numItems;
26 const len = arr.length;
27 let i = 0;
28
29 for (; i < len; i += increment) {
30 result.push(arr[Math.floor(i)]);
31 }
32 return result;
33}
34
35/**
36 * @param {Scale} scale

Callers 2

updateMethod · 0.85
_getLabelSizesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected