(changed, replay)
| 674 | } |
| 675 | |
| 676 | update(changed, replay) { |
| 677 | const options = this.options.setContext(this.getContext()); |
| 678 | const active = this._active; |
| 679 | let properties; |
| 680 | let tooltipItems = []; |
| 681 | |
| 682 | if (active.length) { |
| 683 | tooltipItems = this._createItems(options); |
| 684 | } |
| 685 | |
| 686 | // Hide the tooltip when nothing is active or every item was filtered |
| 687 | // out, so content callbacks are not invoked with an empty item array |
| 688 | if (!tooltipItems.length) { |
| 689 | if (active.length) { |
| 690 | // Every item was filtered out: clear the content so the previous |
| 691 | // body is not drawn with the cleared label colors while fading out |
| 692 | this.title = []; |
| 693 | this.beforeBody = []; |
| 694 | this.body = []; |
| 695 | this.afterBody = []; |
| 696 | this.footer = []; |
| 697 | const position = positioners[options.position].call(this, active, this._eventPosition); |
| 698 | if (position !== false) { |
| 699 | // _positionChanged() compares against the caret, so a repeated event on a filtered item is not a position change |
| 700 | this.caretX = position.x; |
| 701 | this.caretY = position.y; |
| 702 | } |
| 703 | } |
| 704 | if (this.opacity !== 0) { |
| 705 | properties = { |
| 706 | opacity: 0 |
| 707 | }; |
| 708 | } |
| 709 | } else { |
| 710 | const position = positioners[options.position].call(this, active, this._eventPosition); |
| 711 | |
| 712 | this.title = this.getTitle(tooltipItems, options); |
| 713 | this.beforeBody = this.getBeforeBody(tooltipItems, options); |
| 714 | this.body = this.getBody(tooltipItems, options); |
| 715 | this.afterBody = this.getAfterBody(tooltipItems, options); |
| 716 | this.footer = this.getFooter(tooltipItems, options); |
| 717 | |
| 718 | const size = this._size = getTooltipSize(this, options); |
| 719 | const positionAndSize = Object.assign({}, position, size); |
| 720 | const alignment = determineAlignment(this.chart, options, positionAndSize); |
| 721 | const backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, this.chart); |
| 722 | |
| 723 | this.xAlign = alignment.xAlign; |
| 724 | this.yAlign = alignment.yAlign; |
| 725 | |
| 726 | properties = { |
| 727 | opacity: 1, |
| 728 | x: backgroundPoint.x, |
| 729 | y: backgroundPoint.y, |
| 730 | width: size.width, |
| 731 | height: size.height, |
| 732 | caretX: position.x, |
| 733 | caretY: position.y |
no test coverage detected