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

Function findOrAddLabel

src/scales/scale.category.js:14–21  ·  view source on GitHub ↗
(labels, raw, index, addedLabels)

Source from the content-addressed store, hash-verified

12};
13
14function findOrAddLabel(labels, raw, index, addedLabels) {
15 const first = labels.indexOf(raw);
16 if (first === -1) {
17 return addIfString(labels, raw, index, addedLabels);
18 }
19 const last = labels.lastIndexOf(raw);
20 return first !== last ? index : first;
21}
22
23const validIndex = (index, max) => index === null ? null : _limitValue(Math.round(index), 0, max);
24

Callers 1

parseMethod · 0.85

Calls 1

addIfStringFunction · 0.85

Tested by

no test coverage detected