(
// Use Model<TooltipOption> instead of TooltipModel because this model may be from series or other options.
// Instead of top level tooltip.
tooltipModel: Model<TooltipOption>,
defaultHtml: string,
params: TooltipCallbackDataParams | TooltipCallbackDataParams[],
asyncTicket: string,
x: number,
y: number,
positionExpr: TooltipOption['position'],
el: ECElement,
markupStyleCreator: TooltipMarkupStyleCreator
)
| 810 | } |
| 811 | |
| 812 | private _showTooltipContent( |
| 813 | // Use Model<TooltipOption> instead of TooltipModel because this model may be from series or other options. |
| 814 | // Instead of top level tooltip. |
| 815 | tooltipModel: Model<TooltipOption>, |
| 816 | defaultHtml: string, |
| 817 | params: TooltipCallbackDataParams | TooltipCallbackDataParams[], |
| 818 | asyncTicket: string, |
| 819 | x: number, |
| 820 | y: number, |
| 821 | positionExpr: TooltipOption['position'], |
| 822 | el: ECElement, |
| 823 | markupStyleCreator: TooltipMarkupStyleCreator |
| 824 | ) { |
| 825 | // Reset ticket |
| 826 | this._ticket = ''; |
| 827 | |
| 828 | if (!tooltipModel.get('showContent') || !tooltipModel.get('show')) { |
| 829 | return; |
| 830 | } |
| 831 | |
| 832 | const tooltipContent = this._tooltipContent; |
| 833 | tooltipContent.setEnterable(tooltipModel.get('enterable')); |
| 834 | |
| 835 | const formatter = tooltipModel.get('formatter'); |
| 836 | positionExpr = positionExpr || tooltipModel.get('position'); |
| 837 | let html: string | HTMLElement | HTMLElement[] = defaultHtml; |
| 838 | const nearPoint = this._getNearestPoint( |
| 839 | [x, y], |
| 840 | params, |
| 841 | tooltipModel.get('trigger'), |
| 842 | tooltipModel.get('borderColor'), |
| 843 | tooltipModel.get('defaultBorderColor', true) |
| 844 | ); |
| 845 | const nearPointColor = nearPoint.color; |
| 846 | |
| 847 | if (formatter) { |
| 848 | if (isString(formatter)) { |
| 849 | const useUTC = tooltipModel.ecModel.get('useUTC'); |
| 850 | const params0 = isArray(params) ? params[0] : params; |
| 851 | const isTimeAxis = params0 && params0.axisType && params0.axisType.indexOf('time') >= 0; |
| 852 | html = formatter; |
| 853 | if (isTimeAxis) { |
| 854 | html = timeFormat(params0.axisValue, html, useUTC); |
| 855 | } |
| 856 | html = formatTpl(html, params, true); |
| 857 | } |
| 858 | else if (isFunction(formatter)) { |
| 859 | const callback = bind(function (cbTicket: string, html: string | HTMLElement | HTMLElement[]) { |
| 860 | if (cbTicket === this._ticket) { |
| 861 | tooltipContent.setContent(html, markupStyleCreator, tooltipModel, nearPointColor, positionExpr); |
| 862 | this._updatePosition( |
| 863 | tooltipModel, positionExpr, x, y, tooltipContent, params, el |
| 864 | ); |
| 865 | } |
| 866 | }, this); |
| 867 | this._ticket = asyncTicket; |
| 868 | html = formatter(params, asyncTicket, callback); |
| 869 | } |
no test coverage detected