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

Method update

src/plugins/plugin.tooltip.js:638–689  ·  view source on GitHub ↗
(changed, replay)

Source from the content-addressed store, hash-verified

636 }
637
638 update(changed, replay) {
639 const options = this.options.setContext(this.getContext());
640 const active = this._active;
641 let properties;
642 let tooltipItems = [];
643
644 if (!active.length) {
645 if (this.opacity !== 0) {
646 properties = {
647 opacity: 0
648 };
649 }
650 } else {
651 const position = positioners[options.position].call(this, active, this._eventPosition);
652 tooltipItems = this._createItems(options);
653
654 this.title = this.getTitle(tooltipItems, options);
655 this.beforeBody = this.getBeforeBody(tooltipItems, options);
656 this.body = this.getBody(tooltipItems, options);
657 this.afterBody = this.getAfterBody(tooltipItems, options);
658 this.footer = this.getFooter(tooltipItems, options);
659
660 const size = this._size = getTooltipSize(this, options);
661 const positionAndSize = Object.assign({}, position, size);
662 const alignment = determineAlignment(this.chart, options, positionAndSize);
663 const backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, this.chart);
664
665 this.xAlign = alignment.xAlign;
666 this.yAlign = alignment.yAlign;
667
668 properties = {
669 opacity: 1,
670 x: backgroundPoint.x,
671 y: backgroundPoint.y,
672 width: size.width,
673 height: size.height,
674 caretX: position.x,
675 caretY: position.y
676 };
677 }
678
679 this._tooltipItems = tooltipItems;
680 this.$context = undefined;
681
682 if (properties) {
683 this._resolveAnimations().update(this, properties);
684 }
685
686 if (changed && options.external) {
687 options.external.call(this, {chart: this.chart, tooltip: this, replay});
688 }
689 }
690
691 drawCaret(tooltipPoint, ctx, size, options) {
692 const caretPosition = this.getCaretPosition(tooltipPoint, size, options);

Callers 2

setActiveElementsMethod · 0.95
handleEventMethod · 0.95

Calls 13

getContextMethod · 0.95
_createItemsMethod · 0.95
getTitleMethod · 0.95
getBeforeBodyMethod · 0.95
getBodyMethod · 0.95
getAfterBodyMethod · 0.95
getFooterMethod · 0.95
_resolveAnimationsMethod · 0.95
getTooltipSizeFunction · 0.85
determineAlignmentFunction · 0.85
getBackgroundPointFunction · 0.85
setContextMethod · 0.80

Tested by

no test coverage detected