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

Method updateElements

src/controllers/controller.bar.ts:508–540  ·  view source on GitHub ↗
(bars: BarElement[], start: number, count: number, mode: UpdateMode)

Source from the content-addressed store, hash-verified

506 }
507
508 override updateElements(bars: BarElement[], start: number, count: number, mode: UpdateMode): void {
509 const reset = mode === 'reset';
510 const {index, _cachedMeta: {vScale}} = this;
511 const base = vScale.getBasePixel();
512 const horizontal = vScale.isHorizontal();
513 const ruler = this._getRuler();
514 const {sharedOptions, includeOptions} = this._getSharedOptions(start, mode);
515
516 for (let i = start; i < start + count; i++) {
517 const parsed: BarParsed = this.getParsed(i);
518 const vpixels: {base: number; head: number; size?: number} = reset || isNullOrUndef(parsed[vScale.axis]) ? {base, head: base} : this._calculateBarValuePixels(i);
519 const ipixels = this._calculateBarIndexPixels(i, ruler);
520 const stack = (parsed._stacks || {})[vScale.axis];
521
522 const properties: BarProperties = {
523 horizontal,
524 base: vpixels.base,
525 enableBorderRadius: !stack || isFloatBar(parsed._custom) || (index === stack._top || index === stack._bottom),
526 x: horizontal ? vpixels.head : ipixels.center,
527 y: horizontal ? ipixels.center : vpixels.head,
528 height: horizontal ? ipixels.size : Math.abs(vpixels.size),
529 width: horizontal ? Math.abs(vpixels.size) : ipixels.size
530 };
531
532 if (includeOptions) {
533 properties.options = sharedOptions || this.resolveDataElementOptions(i, bars[i].active ? 'active' : mode);
534 }
535 const options = properties.options || bars[i].options;
536 setBorderSkipped(properties, options, stack, index);
537 setInflateAmount(properties, options, ruler.ratio);
538 this.updateElement(bars[i], i, properties, mode);
539 }
540 }
541
542 /**
543 * Returns the stacks based on groups and bar visibility.

Callers 1

updateMethod · 0.95

Calls 13

_getRulerMethod · 0.95
isNullOrUndefFunction · 0.85
isFloatBarFunction · 0.85
setBorderSkippedFunction · 0.85
setInflateAmountFunction · 0.85
_getSharedOptionsMethod · 0.80
getParsedMethod · 0.80
updateElementMethod · 0.80
getBasePixelMethod · 0.65
isHorizontalMethod · 0.65

Tested by

no test coverage detected