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

Method updateElements

src/controllers/controller.bar.js:393–425  ·  view source on GitHub ↗
(bars, start, count, mode)

Source from the content-addressed store, hash-verified

391 }
392
393 updateElements(bars, start, count, mode) {
394 const reset = mode === 'reset';
395 const {index, _cachedMeta: {vScale}} = this;
396 const base = vScale.getBasePixel();
397 const horizontal = vScale.isHorizontal();
398 const ruler = this._getRuler();
399 const {sharedOptions, includeOptions} = this._getSharedOptions(start, mode);
400
401 for (let i = start; i < start + count; i++) {
402 const parsed = this.getParsed(i);
403 const vpixels = reset || isNullOrUndef(parsed[vScale.axis]) ? {base, head: base} : this._calculateBarValuePixels(i);
404 const ipixels = this._calculateBarIndexPixels(i, ruler);
405 const stack = (parsed._stacks || {})[vScale.axis];
406
407 const properties = {
408 horizontal,
409 base: vpixels.base,
410 enableBorderRadius: !stack || isFloatBar(parsed._custom) || (index === stack._top || index === stack._bottom),
411 x: horizontal ? vpixels.head : ipixels.center,
412 y: horizontal ? ipixels.center : vpixels.head,
413 height: horizontal ? ipixels.size : Math.abs(vpixels.size),
414 width: horizontal ? Math.abs(vpixels.size) : ipixels.size
415 };
416
417 if (includeOptions) {
418 properties.options = sharedOptions || this.resolveDataElementOptions(i, bars[i].active ? 'active' : mode);
419 }
420 const options = properties.options || bars[i].options;
421 setBorderSkipped(properties, options, stack, index);
422 setInflateAmount(properties, options, ruler.ratio);
423 this.updateElement(bars[i], i, properties, mode);
424 }
425 }
426
427 /**
428 * 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