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

Function parseArrayOrPrimitive

src/controllers/controller.bar.ts:278–294  ·  view source on GitHub ↗
(meta: BarMeta, data: unknown[], start: number, count: number)

Source from the content-addressed store, hash-verified

276}
277
278function parseArrayOrPrimitive(meta: BarMeta, data: unknown[], start: number, count: number): BarParsed[] {
279 const iScale = meta.iScale;
280 const vScale = meta.vScale;
281 const labels = iScale.getLabels();
282 const singleScale = iScale === vScale;
283 const parsed: BarParsed[] = [];
284 let i: number, ilen: number, item: BarParsed, entry: unknown;
285
286 for (i = start, ilen = start + count; i < ilen; ++i) {
287 entry = data[i];
288 item = {};
289 // With a single scale, `parseValue` overwrites this `true` with the parsed value.
290 item[iScale.axis] = (singleScale || iScale.parse(labels[i], i)) as number;
291 parsed.push(parseValue(entry, item, vScale, i));
292 }
293 return parsed;
294}
295
296function isFloatBar(custom: BarCustom | undefined) {
297 return custom && custom.barStart !== undefined && custom.barEnd !== undefined;

Callers 2

parsePrimitiveDataMethod · 0.85
parseArrayDataMethod · 0.85

Calls 3

parseValueFunction · 0.85
getLabelsMethod · 0.65
parseMethod · 0.65

Tested by

no test coverage detected